dev: cli: fix recent command parsing breakage; more tests
This commit is contained in:
parent
b71634a4ee
commit
7ac154e0b8
@ -268,7 +268,7 @@ main = withGhcDebug' $ do
|
|||||||
-- If no command argument was provided, or if cmdargs fails because
|
-- If no command argument was provided, or if cmdargs fails because
|
||||||
-- the command line contains a bad flag or wrongly present/missing flag value,
|
-- the command line contains a bad flag or wrongly present/missing flag value,
|
||||||
-- cmdname will be "".
|
-- cmdname will be "".
|
||||||
args = confallgenargs <> cliargswithcmdfirstwithoutclispecific
|
args = [confcmdarg | not $ null confcmdarg] <> cliargswithcmdfirstwithoutclispecific
|
||||||
cmdname = stringopt "command" $ cmdargsParse "for command name" (mainmode addons) args
|
cmdname = stringopt "command" $ cmdargsParse "for command name" (mainmode addons) args
|
||||||
badcmdprovided = null cmdname && not nocmdprovided
|
badcmdprovided = null cmdname && not nocmdprovided
|
||||||
isaddoncmd = not (null cmdname) && cmdname `elem` addons
|
isaddoncmd = not (null cmdname) && cmdname `elem` addons
|
||||||
|
|||||||
@ -154,3 +154,13 @@ $ hledger -f /dev/null --no-conf --conf nosuchfile check
|
|||||||
$ hledger --debug -f /dev/null --conf /dev/null --no-conf >/dev/null
|
$ hledger --debug -f /dev/null --conf /dev/null --no-conf >/dev/null
|
||||||
>2 /ignoring config files/
|
>2 /ignoring config files/
|
||||||
|
|
||||||
|
# ** 25. Having general options in a conf file doesn't break cli command parsing.
|
||||||
|
$ echo '--pretty' >$$.conf; hledger -f /dev/null --conf $$.conf files; rm -f $$.conf
|
||||||
|
/dev/null
|
||||||
|
|
||||||
|
# ** 26. An initial non-flag general argument in a conf file is used as the command.
|
||||||
|
$ echo 'files' >$$.conf; hledger stats -f /dev/null --conf $$.conf; rm -f $$.conf
|
||||||
|
|
||||||
|
# ** 27. A non-flag general argument that's not first in the conf file is note used as the command.
|
||||||
|
$ echo '--pretty files' >$$.conf; hledger stats -f /dev/null --conf $$.conf; rm -f $$.conf
|
||||||
|
> /Runtime stats/
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user