diff --git a/hledger/Hledger/Cli/CliOptions.hs b/hledger/Hledger/Cli/CliOptions.hs index b29e6d914..af9682eed 100644 --- a/hledger/Hledger/Cli/CliOptions.hs +++ b/hledger/Hledger/Cli/CliOptions.hs @@ -12,6 +12,7 @@ module Hledger.Cli.CliOptions ( -- * cmdargs flags & modes helpflags, detailedversionflag, + flattreeflags, hiddenflags, inputflags, reportflags, @@ -190,6 +191,13 @@ 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" + ] + -- | Common flags that are accepted but not shown in --help, -- such as --effective, --aux-date. hiddenflags :: [Flag RawOpts] diff --git a/hledger/Hledger/Cli/Commands/Accounts.hs b/hledger/Hledger/Cli/Commands/Accounts.hs index 20fba215a..744b7afa8 100644 --- a/hledger/Hledger/Cli/Commands/Accounts.hs +++ b/hledger/Hledger/Cli/Commands/Accounts.hs @@ -38,8 +38,8 @@ accountsmode = hledgerCommandMode $(embedFileRelative "Hledger/Cli/Commands/Accounts.txt") [flagNone ["declared"] (setboolopt "declared") "show account names declared with account directives" ,flagNone ["used"] (setboolopt "used") "show account names referenced by transactions" - ,flagNone ["tree"] (setboolopt "tree") "show short account names, as a tree" ,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" ] [generalflagsgroup1] diff --git a/hledger/Hledger/Cli/Commands/Balance.hs b/hledger/Hledger/Cli/Commands/Balance.hs index 695891652..ec3b712d2 100644 --- a/hledger/Hledger/Cli/Commands/Balance.hs +++ b/hledger/Hledger/Cli/Commands/Balance.hs @@ -279,20 +279,20 @@ balancemode = hledgerCommandMode "show balance change accumulated across periods (in multicolumn reports)" ,flagNone ["historical","H"] (setboolopt "historical") "show historical ending balance in each period (includes postings before report start date)\n " - ,flagNone ["tree"] (setboolopt "tree") "show accounts as a tree; amounts include subaccounts (default in simple reports)" - ,flagNone ["flat"] (setboolopt "flat") "show accounts as a list; amounts exclude subaccounts except when account is depth-clipped (default in multicolumn reports)\n " + ] + ++ flattreeflags ++ + [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)" ,flagNone ["no-total","N"] (setboolopt "no-total") "omit the final total row" - ,flagReq ["drop"] (\s opts -> Right $ setopt "drop" s opts) "N" "omit N leading account name parts (in flat mode)" ,flagNone ["no-elide"] (setboolopt "no-elide") "don't squash boring parent accounts (in tree mode)" ,flagReq ["format"] (\s opts -> Right $ setopt "format" s opts) "FORMATSTR" "use this custom line format (in simple reports)" ,flagNone ["pretty-tables"] (setboolopt "pretty-tables") "use unicode to display prettier tables" ,flagNone ["sort-amount","S"] (setboolopt "sort-amount") "sort by amount instead of account code/name (in flat mode). With multiple columns, sorts by the row total, or by row average if that is displayed." - ,flagNone ["budget"] (setboolopt "budget") "show performance compared to budget goals defined by periodic transactions" + ,flagNone ["percent", "%"] (setboolopt "percent") "express values in percentage of each column's total" ,flagNone ["invert"] (setboolopt "invert") "display all amounts with reversed sign" ,flagNone ["transpose"] (setboolopt "transpose") "transpose rows and columns" - ,flagNone ["percent", "%"] (setboolopt "percent") "express values in percentage of each column's total" + ,flagNone ["budget"] (setboolopt "budget") "show performance compared to budget goals defined by periodic transactions" ,outputFormatFlag ["txt","html","csv","json"] ,outputFileFlag ] diff --git a/hledger/Hledger/Cli/CompoundBalanceCommand.hs b/hledger/Hledger/Cli/CompoundBalanceCommand.hs index 5440cf14e..5526c9337 100644 --- a/hledger/Hledger/Cli/CompoundBalanceCommand.hs +++ b/hledger/Hledger/Cli/CompoundBalanceCommand.hs @@ -53,8 +53,8 @@ data CompoundBalanceCommandSpec = CompoundBalanceCommandSpec { compoundBalanceCommandMode :: CompoundBalanceCommandSpec -> Mode RawOpts compoundBalanceCommandMode CompoundBalanceCommandSpec{..} = hledgerCommandMode - cbcdoc - [flagNone ["change"] (setboolopt "change") + cbcdoc + ([flagNone ["change"] (setboolopt "change") ("show balance change in each period" ++ defType PeriodChange) ,flagNone ["cumulative"] (setboolopt "cumulative") ("show balance change accumulated across periods (in multicolumn reports)" @@ -64,12 +64,12 @@ compoundBalanceCommandMode CompoundBalanceCommandSpec{..} = ("show historical ending balance in each period (includes postings before report start date)" ++ defType HistoricalBalance ) - ,flagNone ["flat"] (setboolopt "flat") "show accounts as a list" - ,flagReq ["drop"] (\s opts -> Right $ setopt "drop" s opts) "N" "flat mode: omit N leading account name parts" - ,flagNone ["no-total","N"] (setboolopt "no-total") "omit the final total row" - ,flagNone ["tree"] (setboolopt "tree") "show accounts as a tree; amounts include subaccounts (default in simple reports)" + ] + ++ flattreeflags ++ + [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)" + ,flagNone ["no-total","N"] (setboolopt "no-total") "omit the final total row" ,flagNone ["no-elide"] (setboolopt "no-elide") "don't squash boring parent accounts (in tree mode)" ,flagReq ["format"] (\s opts -> Right $ setopt "format" s opts) "FORMATSTR" "use this custom line format (in simple reports)" ,flagNone ["pretty-tables"] (setboolopt "pretty-tables") "use unicode when displaying tables" @@ -77,7 +77,7 @@ compoundBalanceCommandMode CompoundBalanceCommandSpec{..} = ,flagNone ["percent", "%"] (setboolopt "percent") "express values in percentage of each column's total" ,outputFormatFlag ["txt","html","csv","json"] ,outputFileFlag - ] + ]) [generalflagsgroup1] hiddenflags ([], Just $ argsFlag "[QUERY]")