make --width and --debug require an argument (fixes #149)

This is a workaround for a cmdargs limitation. Having "--debug 2"
or "--width 100" produce no output (because the number is parsed
as a separate argument) is too annoying.
This commit is contained in:
Simon Michael 2014-07-03 07:31:52 -07:00
parent c31710d942
commit 3669422bbf
3 changed files with 4 additions and 4 deletions

View File

@ -81,7 +81,7 @@ helpflags :: [Flag RawOpts]
helpflags = [ helpflags = [
flagNone ["help","h"] (setboolopt "help") "show general help or (after command) command help" flagNone ["help","h"] (setboolopt "help") "show general help or (after command) command help"
-- ,flagNone ["browse-args"] (setboolopt "browse-args") "use a web UI to select options and build up a command line" -- ,flagNone ["browse-args"] (setboolopt "browse-args") "use a web UI to select options and build up a command line"
,flagOpt "1" ["debug"] (\s opts -> Right $ setopt "debug" s opts) "N" "show debug output (increase N for more)" ,flagReq ["debug"] (\s opts -> Right $ setopt "debug" s opts) "N" "show debug output (increase N for more detail)"
,flagNone ["version"] (setboolopt "version") "show version information" ,flagNone ["version"] (setboolopt "version") "show version information"
] ]

View File

@ -31,7 +31,7 @@ registermode = (defCommandMode $ ["register"] ++ aliases) {
flagNone ["historical","H"] (\opts -> setboolopt "historical" opts) "include prior postings in the running total" flagNone ["historical","H"] (\opts -> setboolopt "historical" opts) "include prior postings in the running total"
,flagNone ["average","A"] (\opts -> setboolopt "average" opts) "show a running average instead of the running total" ,flagNone ["average","A"] (\opts -> setboolopt "average" opts) "show a running average instead of the running total"
,flagNone ["related","r"] (\opts -> setboolopt "related" opts) "show postings' siblings instead" ,flagNone ["related","r"] (\opts -> setboolopt "related" opts) "show postings' siblings instead"
,flagOpt (show defaultWidthWithFlag) ["width","w"] (\s opts -> Right $ setopt "width" s opts) "N" "set output width to 120, or N (default: 80)" ,flagReq ["width","w"] (\s opts -> Right $ setopt "width" s opts) "N" "set output width (default: 80)"
] ]
,groupHidden = [] ,groupHidden = []
,groupNamed = [generalflagsgroup1] ,groupNamed = [generalflagsgroup1]

View File

@ -122,12 +122,12 @@ hledgerdev --daily register
>>>=1 >>>=1
# 12. help and input flags can go before command # 12. help and input flags can go before command
hledgerdev -f /dev/null --alias somealiases --rules-file -? -h --help --version --debug register --daily hledgerdev -f /dev/null --alias somealiases --rules-file -? -h --help --version --debug 1 register --daily
>>> /^hledger \[COMMAND\]/ >>> /^hledger \[COMMAND\]/
>>>=0 >>>=0
# 13. or after it, and spaces in options are optional # 13. or after it, and spaces in options are optional
hledgerdev register -f/dev/null --alias=somealiases --rules-file -? -h --help --version --debug --daily hledgerdev register -f/dev/null --alias=somealiases --rules-file -? -h --help --version --debug 1 --daily
>>> /^register \[OPTIONS\]/ >>> /^register \[OPTIONS\]/
>>>=0 >>>=0