Skip to content

Commit 7f9d4ad

Browse files
committed
feat(curl): support many more option arg (non)completions
1 parent 837cbba commit 7f9d4ad

File tree

1 file changed

+73
-22
lines changed

1 file changed

+73
-22
lines changed

completions/curl

+73-22
Original file line numberDiff line numberDiff line change
@@ -6,40 +6,50 @@ _curl()
66
_init_completion || return
77

88
case $prev in
9-
--ciphers | --connect-timeout | --continue-at | --form | --form-string | \
10-
--ftp-account | --ftp-alternative-to-user | --ftp-port | --header | \
11-
--hostpubmd5 | --keepalive-time | --krb | --limit-rate | --local-port | \
12-
--mail-from | --mail-rcpt | --max-filesize | --max-redirs | --max-time | --pass | \
13-
--proto | --proto-redir | --proxy-user | --proxy1.0 | --quote | --range | \
14-
--request | --retry | --retry-delay | --retry-max-time | \
15-
--socks5-gssapi-service | --telnet-option | --tftp-blksize | --time-cond | \
16-
--url | --user | --user-agent | --version | --write-out | --resolve | --tlsuser | \
17-
--tlspassword | -!(-*)[CFPHmQrXtzuAVw])
18-
return
19-
;;
20-
--config | --cookie | --cookie-jar | --dump-header | --egd-file | \
21-
--key | --libcurl | --output | --random-file | --upload-file | --trace | \
22-
--trace-ascii | --netrc-file | -!(-*)[KbcDoT])
9+
--abstract-unix-socket | --alt-svc | --config | --cookie | \
10+
--cookie-jar | --dump-header | --egd-file | --etag-compare | \
11+
--etag-save | --hsts | --key | --libcurl | --netrc-file | \
12+
--output | --proxy-key | --random-file | --trace | --trace-ascii | \
13+
--unix-socket | --upload-file | -!(-*)[KbcDoT])
2314
_filedir
2415
return
2516
;;
26-
--cacert | --cert | -!(-*)E)
17+
--ciphers | --connect-timeout | --connect-to | --continue-at | \
18+
--curves | --data-raw | --doh-url | --expect100-timeout | --form | \
19+
--form-string | --ftp-account | --ftp-alternative-to-user | \
20+
--happy-eyeballs-timeout-ms | --hostpubmd5 | --keepalive-time | \
21+
--limit-rate | --local-port | --login-options | --mail-auth | \
22+
--mail-from | --mail-rcpt | --max-filesize | --max-redirs | \
23+
--max-time | --pass | --proto | --proto-default | --proto-redir | \
24+
--proxy-ciphers | --proxy-pass | --proxy-service-name | \
25+
--proxy-tls13-ciphers | --proxy-tlspassword | --proxy-tlsuser | \
26+
--proxy-user | --proxy1.0 | --quote | --range | --referer | \
27+
--resolve | --retry | --retry-delay | --retry-max-time | \
28+
--sasl-authzid | --service-name | --socks5-gssapi-service | \
29+
--speed-limit | --speed-time | --telnet-option | --tftp-blksize | \
30+
--time-cond | --tls13-ciphers | --tlspassword | --tlsuser | \
31+
--url | --user | --user-agent | --version | --write-out | \
32+
-!(-*)[CFmQreYytzuAVw])
33+
return
34+
;;
35+
--cacert | --cert | --proxy-cacert | --proxy-cert | -!(-*)E)
2736
_filedir '@(c?(e)rt|cer|pem|der)'
2837
return
2938
;;
30-
--capath)
39+
--capath | --output-dir | --proxy-capath)
3140
_filedir -d
3241
return
3342
;;
34-
--cert-type | --key-type)
43+
--cert-type | --key-type | --proxy-cert-type | --proxy-key-type)
3544
COMPREPLY=($(compgen -W 'DER PEM ENG' -- "$cur"))
3645
return
3746
;;
38-
--crlfile)
47+
--crlfile | --proxy-crlfile)
3948
_filedir crl
4049
return
4150
;;
42-
--data | --data-ascii | --data-binary | --data-urlencode | -!(-*)d)
51+
--data | --data-ascii | --data-binary | --data-urlencode | --header | \
52+
--proxy-header | -!(-*)[dH])
4353
if [[ $cur == \@* ]]; then
4454
cur=${cur:1}
4555
_filedir
@@ -55,8 +65,27 @@ _curl()
5565
COMPREPLY=($(compgen -W 'none policy always' -- "$cur"))
5666
return
5767
;;
68+
--dns-ipv[46]-addr)
69+
_ip_addresses -${prev:9:1}
70+
return
71+
;;
72+
--dns-servers | --noproxy)
73+
_known_hosts_real -- "${cur##*,}"
74+
_comp_delimited , -W '${COMPREPLY[@]}'
75+
return
76+
;;
5877
--engine)
59-
COMPREPLY=($(compgen -W 'list' -- "$cur"))
78+
local engines=$(
79+
"$1" --engine list 2>/dev/null |
80+
command grep "^[[:space:]]"
81+
)
82+
COMPREPLY=($(compgen -W '$engines list' -- "$cur"))
83+
return
84+
;;
85+
--ftp-port | -!(-*)P)
86+
_available_interfaces -a
87+
_known_hosts_real -- "$cur"
88+
_ip_addresses -a
6089
return
6190
;;
6291
--ftp-method)
@@ -83,20 +112,42 @@ _curl()
83112
COMPREPLY=($(compgen -W '${categories[@]}' -- "$cur"))
84113
return
85114
;;
86-
--proxy | --socks4 | --socks4a | --socks5 | --socks5-hostname | -!(-*)x)
115+
--krb)
116+
COMPREPLY=($(compgen -W 'clear safe confidential private' -- "$cur"))
117+
return
118+
;;
119+
--pinnedpubkey | --proxy-pinnedpubkey)
120+
_filedir '@(pem|der|key)'
121+
return
122+
;;
123+
--preproxy | --proxy | --socks4 | --socks4a | --socks5 | \
124+
--socks5-hostname | -!(-*)x)
87125
_known_hosts_real -- "$cur"
88126
return
89127
;;
90128
--pubkey)
91129
_xfunc ssh _ssh_identityfile pub
92130
return
93131
;;
132+
--request | -!(-*)X)
133+
# TODO: these are valid for http(s) only
134+
COMPREPLY=($(
135+
compgen -W \
136+
'GET HEAD POST PUT DELETE CONNECT OPTIONS TRACE PATCH' \
137+
-- "$cur"
138+
))
139+
return
140+
;;
94141
--stderr)
95142
COMPREPLY=($(compgen -W '-' -- "$cur"))
96143
_filedir
97144
return
98145
;;
99-
--tlsauthtype)
146+
--tls-max)
147+
COMPREPLY=($(compgen -W 'default 1.0 1.1 1.2 1.3' -- "$cur"))
148+
return
149+
;;
150+
--tlsauthtype | --proxy-tlsauthtype)
100151
COMPREPLY=($(compgen -W 'SRP' -- "$cur"))
101152
return
102153
;;

0 commit comments

Comments
 (0)