diff --git a/hledger-ui/Hledger/UI/UIOptions.hs b/hledger-ui/Hledger/UI/UIOptions.hs index d2b6183df..7a57ac41b 100644 --- a/hledger-ui/Hledger/UI/UIOptions.hs +++ b/hledger-ui/Hledger/UI/UIOptions.hs @@ -69,22 +69,31 @@ uiflags = [ -- ,flagNone ["no-elide"] (setboolopt "no-elide") "don't compress empty parent accounts on one line" --uimode :: Mode RawOpts -uimode = (mode "hledger-ui" (setopt "command" "ui" def) - "browse accounts, postings and entries in a full-window TUI" - (argsFlag "[--cash|--bs|--is|--all|--register=ACCT] [QUERY]") []){ - modeGroupFlags = Group { - groupUnnamed = uiflags - ,groupHidden = hiddenflags - ++ - [flagNone ["future"] (setboolopt "forecast") "old flag, use --forecast instead" - ,flagNone ["menu"] (setboolopt "menu") "old flag, menu screen is now the default" - ] - ,groupNamed = [(generalflagsgroup1)] - } - ,modeHelpSuffix=[ - -- "Reads your ~/.hledger.journal file, or another specified by $LEDGER_FILE or -f, and starts the full-window TUI." - ] - } +uimode = + (mode "hledger-ui" (setopt "command" "ui" def) + "browse accounts, postings and entries in a full-window TUI" + (argsFlag "[--cash|--bs|--is|--all|--register=ACCT] [QUERY]") []) + {modeGroupFlags = Group { + groupUnnamed = uiflags + ,groupHidden = hiddenflags + ++ + [flagNone ["future"] (setboolopt "forecast") "old flag, use --forecast instead" + ,flagNone ["menu"] (setboolopt "menu") "old flag, menu screen is now the default" + ] + ,groupNamed = mkgeneralflagsgroups1 uihelpflags + } + ,modeHelpSuffix=[ + -- "Reads your ~/.hledger.journal file, or another specified by $LEDGER_FILE or -f, and starts the full-window TUI." + ] + } + +uihelpflags :: [Flag RawOpts] +uihelpflags = [ + flagNone ["version"] (setboolopt "version") "show version information" + ,flagNone ["help","h"] (setboolopt "help") "show command line help" + ,flagNone ["man"] (setboolopt "man") "show the hledger-ui manual with man" + ,flagNone ["info"] (setboolopt "info") "show the hledger-ui manual with info" + ] -- hledger-ui options, used in hledger-ui and above data UIOpts = UIOpts diff --git a/hledger-web/Hledger/Web/WebOptions.hs b/hledger-web/Hledger/Web/WebOptions.hs index 21b683f88..3c78d304b 100644 --- a/hledger-web/Hledger/Web/WebOptions.hs +++ b/hledger-web/Hledger/Web/WebOptions.hs @@ -112,19 +112,20 @@ webmode = { modeGroupFlags = Group { groupUnnamed = webflags - , groupHidden = - hiddenflags - -- ++ - -- [ flagNone - -- ["binary-filename"] - -- (setboolopt "binary-filename") - -- "show the download filename for this executable, and exit" - -- ] - , groupNamed = [generalflagsgroup1] + , groupHidden = hiddenflags + , groupNamed = mkgeneralflagsgroups1 webhelpflags } , modeHelpSuffix = [] } +webhelpflags :: [Flag RawOpts] +webhelpflags = [ + flagNone ["version"] (setboolopt "version") "show version information" + ,flagNone ["help","h"] (setboolopt "help") "show command line help" + ,flagNone ["man"] (setboolopt "man") "show the hledger-web manual with man" + ,flagNone ["info"] (setboolopt "info") "show the hledger-web manual with info" + ] + -- hledger-web options, used in hledger-web and above data WebOpts = WebOpts { serve_ :: !Bool diff --git a/hledger/Hledger/Cli.hs b/hledger/Hledger/Cli.hs index e46160579..ebe2671b4 100644 --- a/hledger/Hledger/Cli.hs +++ b/hledger/Hledger/Cli.hs @@ -108,9 +108,9 @@ import Hledger.Cli.Version -- | The overall cmdargs mode describing hledger's command-line options and subcommands. mainmode addons = defMode { - modeNames = [progname ++ " [CMD]"] + modeNames = [progname ++ " [COMMAND]"] ,modeArgs = ([], Just $ argsFlag "[ARGS]") - ,modeHelp = unlines ["hledger's main command line interface. Runs builtin commands and other hledger executables. Type \"hledger\" to list available commands."] + ,modeHelp = unlines ["hledger's main command line interface. Run with no ARGS to list commands."] ,modeGroupModes = Group { -- subcommands in the unnamed group, shown first: groupUnnamed = [ @@ -122,12 +122,8 @@ mainmode addons = defMode { ,groupHidden = map fst builtinCommands ++ map addonCommandMode addons } ,modeGroupFlags = Group { - -- flags in named groups: - groupNamed = [ - ( "General input flags", inputflags) - ,("\nGeneral reporting flags", reportflags) - ,("\nGeneral help flags", helpflags) - ] + -- flags in named groups: (keep synced with Hledger.Cli.CliOptions.highlightHelp) + groupNamed = cligeneralflagsgroups1 -- flags in the unnamed group, shown last: ,groupUnnamed = [] -- flags handled but not shown in the help: @@ -135,15 +131,16 @@ mainmode addons = defMode { [detailedversionflag] -- ++ inputflags -- included here so they'll not raise a confusing error if present with no COMMAND } - ,modeHelpSuffix = "Examples:" : - map (progname ++) [ - " list commands" - ," CMD [--] [OPTS] [ARGS] run a command (use -- with addon commands)" - ,"-CMD [OPTS] [ARGS] or run addon commands directly" - ," -h show general usage" - ," CMD -h show command usage" - ," help [MANUAL] show any of the hledger manuals in various formats" - ] + ,modeHelpSuffix = [] + -- "Examples:" : + -- map (progname ++) [ + -- " list commands" + -- ," CMD [--] [OPTS] [ARGS] run a command (use -- with addon commands)" + -- ,"-CMD [OPTS] [ARGS] or run addon commands directly" + -- ," -h show general usage" + -- ," CMD -h show command usage" + -- ," help [MANUAL] show any of the hledger manuals in various formats" + -- ] } -- | Let's go! diff --git a/hledger/Hledger/Cli/Commands/Accounts.hs b/hledger/Hledger/Cli/Commands/Accounts.hs index 22ec50fa4..190ea0c05 100644 --- a/hledger/Hledger/Cli/Commands/Accounts.hs +++ b/hledger/Hledger/Cli/Commands/Accounts.hs @@ -48,7 +48,7 @@ accountsmode = hledgerCommandMode ++ flattreeflags False ++ [flagReq ["drop"] (\s opts -> Right $ setopt "drop" s opts) "N" "flat mode: omit N leading account name parts"] ) - [generalflagsgroup1] + cligeneralflagsgroups1 hiddenflags ([], Just $ argsFlag "[QUERY]") diff --git a/hledger/Hledger/Cli/Commands/Activity.hs b/hledger/Hledger/Cli/Commands/Activity.hs index 515131041..0606b81ab 100644 --- a/hledger/Hledger/Cli/Commands/Activity.hs +++ b/hledger/Hledger/Cli/Commands/Activity.hs @@ -19,7 +19,7 @@ import Hledger.Cli.CliOptions activitymode = hledgerCommandMode $(embedFileRelative "Hledger/Cli/Commands/Activity.txt") [] - [generalflagsgroup1] + cligeneralflagsgroups1 hiddenflags ([], Just $ argsFlag "[QUERY]") diff --git a/hledger/Hledger/Cli/Commands/Aregister.hs b/hledger/Hledger/Cli/Commands/Aregister.hs index 5cf7f6d41..6f177cbfd 100644 --- a/hledger/Hledger/Cli/Commands/Aregister.hs +++ b/hledger/Hledger/Cli/Commands/Aregister.hs @@ -61,7 +61,7 @@ aregistermode = hledgerCommandMode ,outputFormatFlag ["txt","html","csv","tsv","json"] ,outputFileFlag ]) - [generalflagsgroup1] + cligeneralflagsgroups1 hiddenflags ([], Just $ argsFlag "ACCTPAT [QUERY]") diff --git a/hledger/Hledger/Cli/Commands/Balance.hs b/hledger/Hledger/Cli/Commands/Balance.hs index 590d61e1d..e164b644e 100644 --- a/hledger/Hledger/Cli/Commands/Balance.hs +++ b/hledger/Hledger/Cli/Commands/Balance.hs @@ -336,7 +336,7 @@ balancemode = hledgerCommandMode ,outputFileFlag ] ) - [generalflagsgroup1] + cligeneralflagsgroups1 (hiddenflags ++ [ flagNone ["commodity-column"] (setboolopt "commodity-column") "show commodity symbols in a separate column, amounts as bare numbers, one row per commodity" diff --git a/hledger/Hledger/Cli/Commands/Check.hs b/hledger/Hledger/Cli/Commands/Check.hs index 089258938..47e99bde4 100644 --- a/hledger/Hledger/Cli/Commands/Check.hs +++ b/hledger/Hledger/Cli/Commands/Check.hs @@ -22,7 +22,7 @@ checkmode :: Mode RawOpts checkmode = hledgerCommandMode $(embedFileRelative "Hledger/Cli/Commands/Check.txt") [] - [generalflagsgroup1] + cligeneralflagsgroups1 hiddenflags ([], Just $ argsFlag "[CHECKS]") diff --git a/hledger/Hledger/Cli/Commands/Close.hs b/hledger/Hledger/Cli/Commands/Close.hs index 2e94c1ec6..676c4c4ff 100644 --- a/hledger/Hledger/Cli/Commands/Close.hs +++ b/hledger/Hledger/Cli/Commands/Close.hs @@ -53,7 +53,7 @@ closemode = hledgerCommandMode ,flagReq ["open-acct"] (\s opts -> Right $ setopt "open-acct" s opts) "ACCT" "set opening transaction's source account" ,roundFlag ] - [generalflagsgroup1] + cligeneralflagsgroups1 (hiddenflags ++ -- keep supporting old flag names for compatibility [flagNone ["closing"] (setboolopt "close") "old spelling of --close" diff --git a/hledger/Hledger/Cli/Commands/Codes.hs b/hledger/Hledger/Cli/Commands/Codes.hs index aba995269..85a549aa1 100644 --- a/hledger/Hledger/Cli/Commands/Codes.hs +++ b/hledger/Hledger/Cli/Commands/Codes.hs @@ -26,7 +26,7 @@ import Hledger.Cli.CliOptions codesmode = hledgerCommandMode $(embedFileRelative "Hledger/Cli/Commands/Codes.txt") [] - [generalflagsgroup1] + cligeneralflagsgroups1 hiddenflags ([], Just $ argsFlag "[QUERY]") diff --git a/hledger/Hledger/Cli/Commands/Descriptions.hs b/hledger/Hledger/Cli/Commands/Descriptions.hs index 9a6f8a553..98f0661e6 100644 --- a/hledger/Hledger/Cli/Commands/Descriptions.hs +++ b/hledger/Hledger/Cli/Commands/Descriptions.hs @@ -25,7 +25,7 @@ import Hledger.Cli.CliOptions descriptionsmode = hledgerCommandMode $(embedFileRelative "Hledger/Cli/Commands/Descriptions.txt") [] - [generalflagsgroup1] + cligeneralflagsgroups1 hiddenflags ([], Just $ argsFlag "[QUERY]") diff --git a/hledger/Hledger/Cli/Commands/Import.hs b/hledger/Hledger/Cli/Commands/Import.hs index f53c91954..f8c7d9a76 100644 --- a/hledger/Hledger/Cli/Commands/Import.hs +++ b/hledger/Hledger/Cli/Commands/Import.hs @@ -24,7 +24,7 @@ importmode = hledgerCommandMode [flagNone ["catchup"] (setboolopt "catchup") "just mark all transactions as already imported" ,flagNone ["dry-run"] (setboolopt "dry-run") "just show the transactions to be imported" ] - [generalflagsgroup1] + cligeneralflagsgroups1 hiddenflags ([], Just $ argsFlag "FILE [...]") diff --git a/hledger/Hledger/Cli/Commands/Notes.hs b/hledger/Hledger/Cli/Commands/Notes.hs index 83e4a07a0..5b85208dc 100644 --- a/hledger/Hledger/Cli/Commands/Notes.hs +++ b/hledger/Hledger/Cli/Commands/Notes.hs @@ -26,7 +26,7 @@ import Hledger.Cli.CliOptions notesmode = hledgerCommandMode $(embedFileRelative "Hledger/Cli/Commands/Notes.txt") [] - [generalflagsgroup1] + cligeneralflagsgroups1 hiddenflags ([], Just $ argsFlag "[QUERY]") diff --git a/hledger/Hledger/Cli/Commands/Payees.hs b/hledger/Hledger/Cli/Commands/Payees.hs index 2bd8358b2..9df001827 100644 --- a/hledger/Hledger/Cli/Commands/Payees.hs +++ b/hledger/Hledger/Cli/Commands/Payees.hs @@ -28,7 +28,7 @@ payeesmode = hledgerCommandMode [flagNone ["declared"] (setboolopt "declared") "show payees declared with payee directives" ,flagNone ["used"] (setboolopt "used") "show payees referenced by transactions" ] - [generalflagsgroup1] + cligeneralflagsgroups1 hiddenflags ([], Just $ argsFlag "[QUERY]") diff --git a/hledger/Hledger/Cli/Commands/Prices.hs b/hledger/Hledger/Cli/Commands/Prices.hs index 65ac476f1..2b7020864 100644 --- a/hledger/Hledger/Cli/Commands/Prices.hs +++ b/hledger/Hledger/Cli/Commands/Prices.hs @@ -22,7 +22,7 @@ pricesmode = hledgerCommandMode [flagNone ["show-reverse"] (setboolopt "show-reverse") "also show the prices inferred by reversing known prices" ] - [generalflagsgroup1] + cligeneralflagsgroups1 (hiddenflags ++ [flagNone ["costs"] (setboolopt "infer-market-prices") "deprecated, use --infer-market-prices instead" ,flagNone ["inverted-costs"] (setboolopt "show-reverse") "deprecated, use --show-reverse instead" diff --git a/hledger/Hledger/Cli/Commands/Print.hs b/hledger/Hledger/Cli/Commands/Print.hs index e3e8d249a..3f40d299b 100644 --- a/hledger/Hledger/Cli/Commands/Print.hs +++ b/hledger/Hledger/Cli/Commands/Print.hs @@ -51,7 +51,7 @@ printmode = hledgerCommandMode ,outputFormatFlag ["txt","beancount","csv","tsv","json","sql"] ,outputFileFlag ]) - [generalflagsgroup1] + cligeneralflagsgroups1 hiddenflags ([], Just $ argsFlag "[QUERY]") diff --git a/hledger/Hledger/Cli/Commands/Register.hs b/hledger/Hledger/Cli/Commands/Register.hs index 7295979d9..6988d0a62 100644 --- a/hledger/Hledger/Cli/Commands/Register.hs +++ b/hledger/Hledger/Cli/Commands/Register.hs @@ -62,7 +62,7 @@ registermode = hledgerCommandMode ,outputFormatFlag ["txt","csv","tsv","json"] ,outputFileFlag ]) - [generalflagsgroup1] + cligeneralflagsgroups1 hiddenflags ([], Just $ argsFlag "[QUERY]") diff --git a/hledger/Hledger/Cli/Commands/Rewrite.hs b/hledger/Hledger/Cli/Commands/Rewrite.hs index c0fc03164..0fa4f35b2 100644 --- a/hledger/Hledger/Cli/Commands/Rewrite.hs +++ b/hledger/Hledger/Cli/Commands/Rewrite.hs @@ -29,7 +29,7 @@ rewritemode = hledgerCommandMode "add a posting to ACCT, which may be parenthesised. AMTEXPR is either a literal amount, or *N which means the transaction's first matched amount multiplied by N (a decimal number). Two spaces separate ACCT and AMTEXPR." ,flagNone ["diff"] (setboolopt "diff") "generate diff suitable as an input for patch tool" ] - [generalflagsgroup1] + cligeneralflagsgroups1 hiddenflags ([], Just $ argsFlag "[QUERY] --add-posting \"ACCT AMTEXPR\" ...") diff --git a/hledger/Hledger/Cli/Commands/Roi.hs b/hledger/Hledger/Cli/Commands/Roi.hs index edf6c6e25..07e8b61f1 100644 --- a/hledger/Hledger/Cli/Commands/Roi.hs +++ b/hledger/Hledger/Cli/Commands/Roi.hs @@ -44,7 +44,7 @@ roimode = hledgerCommandMode ,flagReq ["profit-loss","pnl"] (\s opts -> Right $ setopt "pnl" s opts) "QUERY" "query to select profit-and-loss or appreciation/valuation transactions" ] - [generalflagsgroup1] + cligeneralflagsgroups1 hiddenflags ([], Just $ argsFlag "[QUERY]") diff --git a/hledger/Hledger/Cli/Commands/Stats.hs b/hledger/Hledger/Cli/Commands/Stats.hs index ff0a32022..2d6249fee 100644 --- a/hledger/Hledger/Cli/Commands/Stats.hs +++ b/hledger/Hledger/Cli/Commands/Stats.hs @@ -43,7 +43,7 @@ statsmode = hledgerCommandMode [ flagNone ["verbose","v"] (setboolopt "verbose") "show more detailed output" ,flagReq ["output-file","o"] (\s opts -> Right $ setopt "output-file" s opts) "FILE" "write output to FILE." ] - [generalflagsgroup1] + cligeneralflagsgroups1 hiddenflags ([], Just $ argsFlag "[QUERY]") diff --git a/hledger/Hledger/Cli/Commands/Tags.hs b/hledger/Hledger/Cli/Commands/Tags.hs index 8277f21d0..bcb392e2f 100644 --- a/hledger/Hledger/Cli/Commands/Tags.hs +++ b/hledger/Hledger/Cli/Commands/Tags.hs @@ -21,7 +21,7 @@ tagsmode = hledgerCommandMode [flagNone ["values"] (setboolopt "values") "list tag values instead of tag names" ,flagNone ["parsed"] (setboolopt "parsed") "show tags/values in the order they were parsed, including duplicates" ] - [generalflagsgroup1] + cligeneralflagsgroups1 hiddenflags ([], Just $ argsFlag "[TAGREGEX [QUERY...]]") diff --git a/hledger/Hledger/Cli/CompoundBalanceCommand.hs b/hledger/Hledger/Cli/CompoundBalanceCommand.hs index 0f0f6be39..fec0983d8 100644 --- a/hledger/Hledger/Cli/CompoundBalanceCommand.hs +++ b/hledger/Hledger/Cli/CompoundBalanceCommand.hs @@ -97,7 +97,7 @@ compoundBalanceCommandMode CompoundBalanceCommandSpec{..} = ,outputFormatFlag ["txt","html","csv","tsv","json"] ,outputFileFlag ]) - [generalflagsgroup1] + cligeneralflagsgroups1 (hiddenflags ++ [ flagNone ["commodity-column"] (setboolopt "commodity-column") "show commodity symbols in a separate column, amounts as bare numbers, one row per commodity" diff --git a/hledger/test/cli/cli.test b/hledger/test/cli/cli.test index 10058b66a..fc70234f3 100644 --- a/hledger/test/cli/cli.test +++ b/hledger/test/cli/cli.test @@ -83,7 +83,7 @@ $ hledger -f somefile # ** 6. with -h, and possibly other common flags present, show general usage $ hledger -h --version -f /dev/null -> /^hledger \[CMD\]/ +> /^hledger \[COMMAND\]/ # ** 7. with -h before a COMMAND, show command usage $ hledger -h balance --cost