_parse_help: Pick long options also from "-f FOO, --foo=FOO".
This commit is contained in:
parent
f815736ffe
commit
b8b46f9c27
@ -788,6 +788,11 @@ _parse_help()
|
||||
"$cmd" ${2:---help} 2>&1 | while read -r line; do
|
||||
|
||||
[[ $line == *([ $'\t'])-* ]] || continue
|
||||
# transform "-f FOO, --foo=FOO" to "-f , --foo=FOO" etc
|
||||
while [[ $line =~ \
|
||||
((^|[^-])-[A-Za-z0-9?][[:space:]]+)\[?[A-Z0-9]+\]? ]]; do
|
||||
line=${line/"${BASH_REMATCH[0]}"/"${BASH_REMATCH[1]}"}
|
||||
done
|
||||
__parse_options "$line"
|
||||
|
||||
done
|
||||
|
@ -113,5 +113,13 @@ set cmd {fn() { printf '%s\n' "----\n---foo\n----- bar"; }; _parse_help fn}
|
||||
assert_bash_list "" $cmd "more than two dashes"
|
||||
sync_after_int
|
||||
|
||||
set cmd {fn() { printf '%s\n' "-f FOO, --foo=FOO"; }; _parse_help fn}
|
||||
assert_bash_list "--foo=" $cmd "-f FOO, --foo=FOO"
|
||||
sync_after_int
|
||||
|
||||
set cmd {fn() { printf '%s\n' "-f [FOO], --foo[=FOO]"; }; _parse_help fn}
|
||||
assert_bash_list "--foo" $cmd "-f \[FOO\], --foo\[=FOO\]"
|
||||
sync_after_int
|
||||
|
||||
|
||||
teardown
|
||||
|
Loading…
x
Reference in New Issue
Block a user