1
1
mirror of https://github.com/wader/fq.git synced 2024-12-23 13:22:58 +03:00

Give proper error on missing short flag

This commit is contained in:
Mattias Wadman 2021-08-09 12:37:48 +02:00
parent 970465996c
commit 514739a149

View File

@ -35,7 +35,9 @@ def args_parse($args; $opts):
( $arg[0:2] as $arg ( $arg[0:2] as $arg
| $flagmap[$arg] as $optname | $flagmap[$arg] as $optname
| ($opts[$optname]? // null) as $opt | ($opts[$optname]? // null) as $opt
| if $opt and $opt.bool then | if $opt == null then
error("\($arg): no such argument")
elif $opt.bool then
_parse_without_arg((["-"+$args[0][2:]]+$args[1:]); $optname) _parse_without_arg((["-"+$args[0][2:]]+$args[1:]); $optname)
else else
error("\($arg): needs an argument") error("\($arg): needs an argument")