Skip to content

Commit 837cbba

Browse files
committed
feat(curl): support versions with --help category support
1 parent f1f5bf8 commit 837cbba

File tree

1 file changed

+17
-3
lines changed

1 file changed

+17
-3
lines changed

completions/curl

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,14 @@ _curl()
77

88
case $prev in
99
--ciphers | --connect-timeout | --continue-at | --form | --form-string | \
10-
--ftp-account | --ftp-alternative-to-user | --ftp-port | --header | --help | \
10+
--ftp-account | --ftp-alternative-to-user | --ftp-port | --header | \
1111
--hostpubmd5 | --keepalive-time | --krb | --limit-rate | --local-port | \
1212
--mail-from | --mail-rcpt | --max-filesize | --max-redirs | --max-time | --pass | \
1313
--proto | --proto-redir | --proxy-user | --proxy1.0 | --quote | --range | \
1414
--request | --retry | --retry-delay | --retry-max-time | \
1515
--socks5-gssapi-service | --telnet-option | --tftp-blksize | --time-cond | \
1616
--url | --user | --user-agent | --version | --write-out | --resolve | --tlsuser | \
17-
--tlspassword | -!(-*)[CFPHhmQrXtzuAVw])
17+
--tlspassword | -!(-*)[CFPHmQrXtzuAVw])
1818
return
1919
;;
2020
--config | --cookie | --cookie-jar | --dump-header | --egd-file | \
@@ -71,6 +71,18 @@ _curl()
7171
_available_interfaces -a
7272
return
7373
;;
74+
--help | -!(-*)h)
75+
local x categories=(
76+
$("$1" --help non-existent-category 2>&1 |
77+
awk '/^[[:space:]]/ {print $1}')
78+
)
79+
for x in "${categories[@]}"; do
80+
# Looks like an option? Likely no --help category support
81+
[[ $x != -* ]] || return
82+
done
83+
COMPREPLY=($(compgen -W '${categories[@]}' -- "$cur"))
84+
return
85+
;;
7486
--proxy | --socks4 | --socks4a | --socks5 | --socks5-hostname | -!(-*)x)
7587
_known_hosts_real -- "$cur"
7688
return
@@ -91,7 +103,9 @@ _curl()
91103
esac
92104

93105
if [[ $cur == -* ]]; then
94-
COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur"))
106+
COMPREPLY=($(compgen -W '$(_parse_help "$1" --help all)' -- "$cur"))
107+
[[ $COMPREPLY ]] ||
108+
COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur"))
95109
fi
96110
} &&
97111
complete -F _curl curl

0 commit comments

Comments
 (0)