cli: Allow --drop in account command in tree mode.

This commit is contained in:
Stephen Morgan 2020-07-07 23:02:54 +10:00 committed by Simon Michael
parent 1425301a8c
commit 5ffe1d7656
2 changed files with 17 additions and 4 deletions

View File

@ -83,7 +83,9 @@ accounts CliOpts{rawopts_=rawopts, reportopts_=ropts} j = do
-- 4. print what remains as a list or tree, maybe applying --drop in the former case
mapM_ (T.putStrLn . render) clippedaccts
where
render a
| tree_ ropts = T.replicate (2 * (accountNameLevel a - 1)) " " <> accountLeafName a
| otherwise = accountNameDrop (drop_ ropts) a
render a = case accountlistmode_ ropts of
ALTree -> T.replicate indent " " <> accountLeafName droppedName
ALFlat -> droppedName
where
indent = 2 * (max 0 (accountNameLevel a - drop_ ropts) - 1)
droppedName = accountNameDrop (drop_ ropts) a

View File

@ -18,6 +18,17 @@ a
aa
>=
# drop in flat mode
$ hledger -f - accounts --flat --drop 1
...
aa
>=
# drop in tree mode
$ hledger -f - accounts --tree --drop 1
...
aa
>=
# filtering transactions by tag
$ hledger -f - accounts tag:foo
a:aa