From 311be367b0755c38cf87b1915e597dcffb3b0a47 Mon Sep 17 00:00:00 2001 From: Simon Michael Date: Fri, 31 May 2024 19:53:23 -1000 Subject: [PATCH] ;doc: cli: simplify, use generic help flags again --- doc/common.m4 | 4 ++-- hledger-ui/Hledger/UI/UIOptions.hs | 11 +---------- hledger-web/Hledger/Web/WebOptions.hs | 11 +---------- hledger/Hledger/Cli.hs | 2 +- hledger/Hledger/Cli/CliOptions.hs | 18 +++++++----------- hledger/Hledger/Cli/Commands/Help.hs | 2 +- 6 files changed, 13 insertions(+), 35 deletions(-) diff --git a/doc/common.m4 b/doc/common.m4 index 8c61e7792..380b50eff 100644 --- a/doc/common.m4 +++ b/doc/common.m4 @@ -131,8 +131,8 @@ General output/reporting flags (supported by some commands): General help flags: -h --help show command line help --tldr show command examples with tldr - --info show the hledger manual with info - --man show the hledger manual with man + --info show the manual with info + --man show the manual with man --version show version information ``` }} )m4_dnl diff --git a/hledger-ui/Hledger/UI/UIOptions.hs b/hledger-ui/Hledger/UI/UIOptions.hs index 2827f348a..9ca95f539 100644 --- a/hledger-ui/Hledger/UI/UIOptions.hs +++ b/hledger-ui/Hledger/UI/UIOptions.hs @@ -80,22 +80,13 @@ uimode = [flagNone ["future"] (setboolopt "forecast") "old flag, use --forecast instead" ,flagNone ["menu"] (setboolopt "menu") "old flag, menu screen is now the default" ] - ,groupNamed = mkgeneralflagsgroups1 uihelpflags + ,groupNamed = mkgeneralflagsgroups1 helpflags } ,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 ["help","h"] (setboolopt "help") "show command line help" - ,flagNone ["tldr"] (setboolopt "tldr") "show command examples with tldr" - ,flagNone ["info"] (setboolopt "info") "show the hledger-ui manual with info" - ,flagNone ["man"] (setboolopt "man") "show the hledger-ui manual with man" - ,flagNone ["version"] (setboolopt "version") "show version information" - ] - -- hledger-ui options, used in hledger-ui and above data UIOpts = UIOpts { uoWatch :: Bool diff --git a/hledger-web/Hledger/Web/WebOptions.hs b/hledger-web/Hledger/Web/WebOptions.hs index 6f06e1fb1..0a02bad70 100644 --- a/hledger-web/Hledger/Web/WebOptions.hs +++ b/hledger-web/Hledger/Web/WebOptions.hs @@ -113,20 +113,11 @@ webmode = Group { groupUnnamed = webflags , groupHidden = hiddenflags - , groupNamed = mkgeneralflagsgroups1 webhelpflags + , groupNamed = mkgeneralflagsgroups1 helpflags } , modeHelpSuffix = [] } -webhelpflags :: [Flag RawOpts] -webhelpflags = [ - flagNone ["help","h"] (setboolopt "help") "show command line help" - ,flagNone ["tldr"] (setboolopt "tldr") "show command examples with tldr" - ,flagNone ["info"] (setboolopt "info") "show the hledger-web manual with info" - ,flagNone ["man"] (setboolopt "man") "show the hledger-web manual with man" - ,flagNone ["version"] (setboolopt "version") "show version information" - ] - -- 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 0a33ae4df..15d19fcb3 100644 --- a/hledger/Hledger/Cli.hs +++ b/hledger/Hledger/Cli.hs @@ -317,7 +317,7 @@ isValue "-" = True isValue ('-':_) = False isValue _ = True -flagstomove = inputflags ++ reportflags ++ clihelpflags +flagstomove = inputflags ++ reportflags ++ helpflags noargflagstomove = concatMap flagNames (filter ((==FlagNone).flagInfo) flagstomove) -- silly special case: if someone is abbreviating --tldr, make sure it works right when written before COMMAND -- (not needed for --info, --man, --version since their abbreviations are ambiguous) diff --git a/hledger/Hledger/Cli/CliOptions.hs b/hledger/Hledger/Cli/CliOptions.hs index 6bcd52567..4f00a117b 100644 --- a/hledger/Hledger/Cli/CliOptions.hs +++ b/hledger/Hledger/Cli/CliOptions.hs @@ -21,7 +21,6 @@ module Hledger.Cli.CliOptions ( -- * cmdargs flags & modes inputflags, reportflags, - clihelpflags, helpflags, helpflagstitle, detailedversionflag, @@ -240,19 +239,16 @@ reportflags = [ ,flagReq ["debug"] (\s opts -> Right $ setopt "debug" s opts) "[1-9]" "show this level of debug output (default: 1)" ] -clihelpflags :: [Flag RawOpts] -clihelpflags = [ +helpflags :: [Flag RawOpts] +helpflags = [ flagNone ["help","h"] (setboolopt "help") "show command line help" ,flagNone ["tldr"] (setboolopt "tldr") "show command examples with tldr" - ,flagNone ["info"] (setboolopt "info") "show the hledger manual with info" - ,flagNone ["man"] (setboolopt "man") "show the hledger manual with man" + ,flagNone ["info"] (setboolopt "info") "show the manual with info" + ,flagNone ["man"] (setboolopt "man") "show the manual with man" ,flagNone ["version"] (setboolopt "version") "show version information" ] -- XXX why are these duplicated in defCommandMode below ? --- temp legacy alias -helpflags = clihelpflags - -- | A hidden flag just for the hledger executable. detailedversionflag :: Flag RawOpts detailedversionflag = flagNone ["version+"] (setboolopt "version+") "show version information with extra detail" @@ -327,9 +323,9 @@ helpflagstitle = "\nGeneral help flags" -- Several subsets of the standard general flags plus CLI help flags, as separate groups. cligeneralflagsgroups1, cligeneralflagsgroups2, cligeneralflagsgroups3 :: [(String, [Flag RawOpts])] -cligeneralflagsgroups1 = mkgeneralflagsgroups1 clihelpflags -cligeneralflagsgroups2 = mkgeneralflagsgroups2 clihelpflags -cligeneralflagsgroups3 = mkgeneralflagsgroups3 clihelpflags +cligeneralflagsgroups1 = mkgeneralflagsgroups1 helpflags +cligeneralflagsgroups2 = mkgeneralflagsgroups2 helpflags +cligeneralflagsgroups3 = mkgeneralflagsgroups3 helpflags -- cmdargs mode constructors diff --git a/hledger/Hledger/Cli/Commands/Help.hs b/hledger/Hledger/Cli/Commands/Help.hs index 02cb89c41..d26ad1ff1 100644 --- a/hledger/Hledger/Cli/Commands/Help.hs +++ b/hledger/Hledger/Cli/Commands/Help.hs @@ -36,7 +36,7 @@ helpmode = hledgerCommandMode ,flagNone ["m"] (setboolopt "man") "show the manual with man" ,flagNone ["p"] (setboolopt "pager") "show the manual with $PAGER or less\n(less is always used if TOPIC is specified)" ] - [(helpflagstitle, clihelpflags)] + [(helpflagstitle, helpflags)] [ flagReq ["debug"] (\s opts -> Right $ setopt "debug" s opts) "[N]" "show debug output (levels 1-9, default: 1)" ]