mirror of
https://github.com/simonmichael/hledger.git
synced 2025-01-06 02:23:46 +03:00
fix: cli: accept --conf with no command
This commit is contained in:
parent
85480a7572
commit
6f3c4c9bf0
@ -140,10 +140,10 @@ mainmode addons = defMode {
|
||||
,modeGroupFlags = Group {
|
||||
-- flags in named groups: (keep synced with Hledger.Cli.CliOptions.highlightHelp)
|
||||
groupNamed = cligeneralflagsgroups1
|
||||
-- flags in the unnamed group, shown last:
|
||||
,groupUnnamed = confflags -- keep synced with dropUnsupportedOpts
|
||||
-- flags handled but not shown in the help:
|
||||
,groupHidden = hiddenflags
|
||||
-- flags in the unnamed group, shown last: (keep synced with dropUnsupportedOpts)
|
||||
,groupUnnamed = confflags
|
||||
-- other flags handled but not shown in help:
|
||||
,groupHidden = hiddenflagsformainmode
|
||||
}
|
||||
,modeHelpSuffix = []
|
||||
-- "Examples:" :
|
||||
|
@ -27,6 +27,7 @@ module Hledger.Cli.CliOptions (
|
||||
flattreeflags,
|
||||
confflags,
|
||||
hiddenflags,
|
||||
hiddenflagsformainmode,
|
||||
-- outputflags,
|
||||
outputFormatFlag,
|
||||
outputFileFlag,
|
||||
@ -267,10 +268,9 @@ confflags = [
|
||||
,flagNone ["no-conf","n"] (setboolopt "no-conf") "ignore any config file"
|
||||
]
|
||||
|
||||
-- | Common flags that are accepted but not shown in --help,
|
||||
-- such as --effective, --aux-date.
|
||||
hiddenflags :: [Flag RawOpts]
|
||||
hiddenflags = [
|
||||
-- | Common legacy flags that are accepted but not shown in --help.
|
||||
hiddenflagsformainmode :: [Flag RawOpts]
|
||||
hiddenflagsformainmode = [
|
||||
flagNone ["effective","aux-date"] (setboolopt "date2") "Ledger-compatible aliases for --date2"
|
||||
,flagNone ["infer-value"] (setboolopt "infer-market-prices") "legacy flag that was renamed"
|
||||
,flagNone ["pretty-tables"] (setopt "pretty" "always") "legacy flag that was renamed"
|
||||
@ -278,7 +278,10 @@ hiddenflags = [
|
||||
,flagNone ["obfuscate"] (setboolopt "obfuscate") "slightly obfuscate hledger's output. Warning, does not give privacy. Formerly --anon." -- #2133, handled by maybeObfuscate
|
||||
,flagReq ["rules-file"] (\s opts -> Right $ setopt "rules" s opts) "RULESFILE" "was renamed to --rules"
|
||||
]
|
||||
++ confflags -- repeated here so subcommands/addons won't error when parsing them
|
||||
|
||||
-- Subcommands/addons add the conf flags, so they won't error if those are present.
|
||||
hiddenflags :: [Flag RawOpts]
|
||||
hiddenflags = hiddenflagsformainmode ++ confflags
|
||||
|
||||
-- | Common output-related flags: --output-file, --output-format...
|
||||
|
||||
|
@ -114,25 +114,29 @@ $ hledger --no-conf check -f/dev/null
|
||||
# ** 15. --conf CONFFILE works with builtin commands.
|
||||
$ hledger --conf /dev/null check -f/dev/null
|
||||
|
||||
# ** 16. When moving options written before the command name:
|
||||
# ** 16. --conf works with no command.
|
||||
$ hledger --conf /dev/null
|
||||
> /Commands/
|
||||
|
||||
# ** 17. When moving options written before the command name:
|
||||
# if the flag name is used in general options and also one or more commands,
|
||||
# the general option's arity determines whether a value is expected.
|
||||
# Here -p is a help command flag taking no value, but also a general option requiring a value,
|
||||
# so the value ("today") is detected.
|
||||
$ hledger -p today check -f/dev/null
|
||||
|
||||
# ** 17. The specially-handled --debug option is also moved properly, with no value:
|
||||
# ** 18. The specially-handled --debug option is also moved properly, with no value:
|
||||
$ hledger --debug check -f/dev/null
|
||||
>2 //
|
||||
|
||||
# ** 18. a joined value:
|
||||
# ** 19. a joined value:
|
||||
$ hledger --debug=1 check -f/dev/null
|
||||
>2 //
|
||||
|
||||
# ** 19. or a separate value:
|
||||
# ** 20. or a separate value:
|
||||
$ hledger --debug 1 check -f/dev/null
|
||||
>2 //
|
||||
|
||||
# ** 20. A short flag with joined value, or multiple valueless short flags joined together, are moved properly.
|
||||
# ** 21. A short flag with joined value, or multiple valueless short flags joined together, are moved properly.
|
||||
$ hledger -f/dev/null -BI check
|
||||
>2 //
|
||||
|
Loading…
Reference in New Issue
Block a user