2017-07-10 11:03:26 +08:00
|
|
|
# Start by testing a bunch of error conditions.
|
|
|
|
|
2017-08-05 03:01:16 +08:00
|
|
|
logmsg No args is an error
|
2017-07-10 11:03:26 +08:00
|
|
|
fish_opt
|
|
|
|
and echo unexpected status $status
|
|
|
|
|
2017-08-05 03:01:16 +08:00
|
|
|
logmsg No short flag or an invalid short flag is an error
|
2017-07-10 11:03:26 +08:00
|
|
|
fish_opt -l help
|
|
|
|
and echo unexpected status $status
|
|
|
|
fish_opt -s help
|
|
|
|
and echo unexpected status $status
|
|
|
|
|
2017-08-05 03:01:16 +08:00
|
|
|
logmsg A required and optional arg makes no sense
|
2017-07-10 11:03:26 +08:00
|
|
|
fish_opt -s h -l help -r --optional-val
|
|
|
|
and echo unexpected status $status
|
|
|
|
|
2017-08-05 03:01:16 +08:00
|
|
|
logmsg A repeated and optional arg makes no sense
|
2017-07-10 11:03:26 +08:00
|
|
|
fish_opt -s h -l help --multiple-vals --optional-val
|
|
|
|
and echo unexpected status $status
|
|
|
|
|
2017-08-05 03:01:16 +08:00
|
|
|
logmsg An unexpected arg not associated with a flag is an error
|
2017-07-10 11:03:26 +08:00
|
|
|
fish_opt -s h -l help hello
|
|
|
|
and echo unexpected status $status
|
|
|
|
|
|
|
|
# Now verify that valid combinations of options produces the correct output.
|
|
|
|
|
2017-08-05 03:01:16 +08:00
|
|
|
logmsg Bool, short only
|
2017-07-10 11:03:26 +08:00
|
|
|
fish_opt -s h
|
|
|
|
or echo unexpected status $status
|
|
|
|
|
2017-08-05 03:01:16 +08:00
|
|
|
logmsg Bool, short and long
|
2017-07-10 11:03:26 +08:00
|
|
|
fish_opt --short h --long help
|
|
|
|
or echo unexpected status $status
|
|
|
|
|
2017-08-05 03:01:16 +08:00
|
|
|
logmsg Bool, short and long but the short var cannot be used
|
2017-07-10 11:03:26 +08:00
|
|
|
fish_opt --short h --long help --long-only
|
|
|
|
|
2017-08-05 03:01:16 +08:00
|
|
|
logmsg Required val, short and long but the short var cannot be used
|
2017-07-10 11:03:26 +08:00
|
|
|
fish_opt --short h --long help -r --long-only
|
|
|
|
or echo unexpected status $status
|
|
|
|
|
2017-08-05 03:01:16 +08:00
|
|
|
logmsg Optional val, short and long valid
|
2017-07-10 11:03:26 +08:00
|
|
|
fish_opt --short h -l help --optional-val
|
|
|
|
or echo unexpected status $status
|
|
|
|
|
2017-08-05 03:01:16 +08:00
|
|
|
logmsg Optional val, short and long but the short var cannot be used
|
2017-07-10 11:03:26 +08:00
|
|
|
fish_opt --short h -l help --optional-val --long-only
|
|
|
|
or echo unexpected status $status
|
|
|
|
|
2017-08-05 03:01:16 +08:00
|
|
|
logmsg Repeated val, short and long valid
|
2017-07-10 11:03:26 +08:00
|
|
|
fish_opt --short h -l help --multiple-vals
|
|
|
|
or echo unexpected status $status
|
|
|
|
|
2017-08-05 03:01:16 +08:00
|
|
|
logmsg Repeated val, short and long but short not valid
|
2017-07-10 11:03:26 +08:00
|
|
|
fish_opt --short h -l help --multiple-vals --long-only
|
|
|
|
or echo unexpected status $status
|
|
|
|
|
2017-08-05 03:01:16 +08:00
|
|
|
logmsg Repeated val, short only
|
2017-07-10 11:03:26 +08:00
|
|
|
fish_opt -s h --multiple-vals
|
|
|
|
or echo unexpected status $status
|
|
|
|
fish_opt -s h --multiple-vals --long-only
|
|
|
|
or echo unexpected status $status
|