From 3669422bbf9d129cf875290ae5eb30a2ac5b635f Mon Sep 17 00:00:00 2001 From: Simon Michael Date: Thu, 3 Jul 2014 07:31:52 -0700 Subject: [PATCH] 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. --- hledger/Hledger/Cli/Options.hs | 2 +- hledger/Hledger/Cli/Register.hs | 2 +- tests/cli/cli.test | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/hledger/Hledger/Cli/Options.hs b/hledger/Hledger/Cli/Options.hs index 66ca581a1..f5f00d206 100644 --- a/hledger/Hledger/Cli/Options.hs +++ b/hledger/Hledger/Cli/Options.hs @@ -81,7 +81,7 @@ helpflags :: [Flag RawOpts] helpflags = [ 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" - ,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" ] diff --git a/hledger/Hledger/Cli/Register.hs b/hledger/Hledger/Cli/Register.hs index 5e460cb84..62793ea83 100644 --- a/hledger/Hledger/Cli/Register.hs +++ b/hledger/Hledger/Cli/Register.hs @@ -31,7 +31,7 @@ registermode = (defCommandMode $ ["register"] ++ aliases) { 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 ["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 = [] ,groupNamed = [generalflagsgroup1] diff --git a/tests/cli/cli.test b/tests/cli/cli.test index 4fe235f6a..2f13aed18 100644 --- a/tests/cli/cli.test +++ b/tests/cli/cli.test @@ -122,12 +122,12 @@ hledgerdev --daily register >>>=1 # 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\]/ >>>=0 # 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\]/ >>>=0