;cli: convert cli.test to latest format

This commit is contained in:
Simon Michael 2020-12-28 06:28:31 -08:00
parent 323303daba
commit 9ff53ab1e0

View File

@ -60,90 +60,61 @@
# version
# 1. --version shows version
hledger --version
>>> /^hledger [0-9]/
>>>2
>>>=0
$ hledger --version
> /^hledger [0-9]/
# 2. --version also works after a command, if it's internal
hledger balance --version
>>> /^hledger [0-9]/
>>>2
>>>=0
$ hledger balance --version
> /^hledger [0-9]/
# help
# 3. with no command, show commands list
hledger
>>> /^Commands/
>>>2
>>>=0
$ hledger
> /^Commands/
# 4. no-command help still works if there are flags, at least the common ones
hledger -fsomefile
>>> /^Commands/
>>>2
>>>=0
$ hledger -fsomefile
> /^Commands/
# 5. and also with a space between flag and value
hledger -f somefile
>>> /^Commands/
>>>2
>>>=0
$ hledger -f somefile
> /^Commands/
# 6. with -h, and possibly other common flags present, show general usage
hledger -h --version -f /dev/null
>>> /^hledger \[CMD\]/
>>>2
>>>=0
$ hledger -h --version -f /dev/null
> /^hledger \[CMD\]/
# 7. with -h before a COMMAND, show command usage
hledger -h balance --cost
>>> /balance \[OPTIONS\]/
>>>2
>>>=0
$ hledger -h balance --cost
> /balance \[OPTIONS\]/
# 8. with -h after a command, show command usage
hledger balance -h
>>> /balance \[OPTIONS\]/
>>>2
>>>=0
$ hledger balance -h
> /balance \[OPTIONS\]/
# 9. with an unrecognised command, give an error and non-zero exit status
hledger nosuchcommand
>>>
>>>2 /not recognized.*to see a list/
>>>=1
$ hledger nosuchcommand
>2 /not recognized.*to see a list/
>= 1
# flag positions
# 10. general flags can go before command
hledger -f /dev/null --alias somealiases --rules-file --debug 1 --daily register
>>>
>>>2
>>>=0
$ hledger -f /dev/null --alias somealiases --rules-file --debug 1 --daily register
# 11. or after it, and spaces in options are optional
hledger register -f/dev/null --alias=somealiases --rules-file -h --version --debug 1 --daily
>>> /^register \[OPTIONS\]/
>>>2
>>>=0
$ hledger register -f/dev/null --alias=somealiases --rules-file -h --version --debug 1 --daily
> /^register \[OPTIONS\]/
# 12. general flags before command should work
hledger -f /dev/null --daily register
>>>
>>>2
>>>=0
$ hledger -f /dev/null --daily register
# 13. command-specific flags can go after command
hledger -f /dev/null register --daily
>>>
>>>2
>>>=0
$ hledger -f /dev/null register --daily
# 14. but not before it
hledger --related register
>>>
>>>2 /Unknown flag: --related/
>>>=1
$ hledger --related register
>2 /Unknown flag: --related/
>= 1