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