;doc: cli: simplify, use generic help flags again

This commit is contained in:
Simon Michael 2024-05-31 19:53:23 -10:00
parent e7b60be4b0
commit 311be367b0
6 changed files with 13 additions and 35 deletions

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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)

View File

@ -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

View File

@ -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)"
]