cli: add -t/-l short flags for --tree/--flat; improve help (#1286)

This commit is contained in:
Simon Michael 2020-07-17 14:15:11 -07:00
parent ba49699728
commit 3636875a5d
4 changed files with 15 additions and 11 deletions

View File

@ -201,11 +201,15 @@ reportflags = [
])
]
-- | Flags for selecting flat/tree mode, used in accounts/balance reports.
flattreeflags :: [Flag RawOpts]
flattreeflags = [
flagNone ["flat"] (setboolopt "flat") "show accounts as a list; amounts exclude subaccounts, except where account is depth-clipped"
,flagNone ["tree"] (setboolopt "tree") "show accounts as a tree; amounts include subaccounts"
-- | Flags for selecting flat/tree mode, used for reports organised by account.
-- With a True argument, shows some extra help about inclusive/exclusive amounts.
flattreeflags :: Bool -> [Flag RawOpts]
flattreeflags showamounthelp = [
flagNone ["flat","l"] (setboolopt "flat")
("show accounts as a flat list (default)"
++ if showamounthelp then ". Amounts exclude subaccount amounts, except where the account is depth-clipped." else "")
,flagNone ["tree","t"] (setboolopt "tree")
("show accounts as a hierarchic tree" ++ if showamounthelp then ". Amounts include subaccount amounts." else "")
]
-- | Common flags that are accepted but not shown in --help,

View File

@ -36,12 +36,12 @@ import Hledger.Cli.CliOptions
-- | Command line options for this command.
accountsmode = hledgerCommandMode
$(embedFileRelative "Hledger/Cli/Commands/Accounts.txt")
[flagNone ["declared"] (setboolopt "declared") "show account names declared with account directives"
([flagNone ["declared"] (setboolopt "declared") "show account names declared with account directives"
,flagNone ["used"] (setboolopt "used") "show account names referenced by transactions"
,flagNone ["flat"] (setboolopt "flat") "show full account names, as a list (default)"
,flagNone ["tree"] (setboolopt "tree") "show short account names, as a tree"
,flagReq ["drop"] (\s opts -> Right $ setopt "drop" s opts) "N" "flat mode: omit N leading account name parts"
]
++ flattreeflags False ++
[flagReq ["drop"] (\s opts -> Right $ setopt "drop" s opts) "N" "flat mode: omit N leading account name parts"
])
[generalflagsgroup1]
hiddenflags
([], Just $ argsFlag "[QUERY]")

View File

@ -280,7 +280,7 @@ balancemode = hledgerCommandMode
,flagNone ["historical","H"] (setboolopt "historical")
"show historical ending balance in each period (includes postings before report start date)\n "
]
++ flattreeflags ++
++ flattreeflags True ++
[flagReq ["drop"] (\s opts -> Right $ setopt "drop" s opts) "N" "omit N leading account name parts (in flat mode)"
,flagNone ["average","A"] (setboolopt "average") "show a row average column (in multicolumn reports)"
,flagNone ["row-total","T"] (setboolopt "row-total") "show a row total column (in multicolumn reports)"

View File

@ -65,7 +65,7 @@ compoundBalanceCommandMode CompoundBalanceCommandSpec{..} =
++ defType HistoricalBalance
)
]
++ flattreeflags ++
++ flattreeflags True ++
[flagReq ["drop"] (\s opts -> Right $ setopt "drop" s opts) "N" "flat mode: omit N leading account name parts"
,flagNone ["average","A"] (setboolopt "average") "show a row average column (in multicolumn reports)"
,flagNone ["row-total","T"] (setboolopt "row-total") "show a row total column (in multicolumn reports)"