#compdef curl

# curl zsh completion

local curcontext="$curcontext" state state_descr line
typeset -A opt_args

local rc=1

_arguments -C -S \
  --aws-sigv4'[Use AWS V4 signature authentication]':'<provider1[\:provider2[\:region[\:service]]]>' \
  --proxy-capath'[CA directory to verify peer against for proxy]':'<dir>':'_path_files -/' \
  {-X,--request}'[Specify request method to use]':'<method>':'(DELETE GET HEAD POST PUT)' \
  {-c,--cookie-jar}'[Write cookies to <filename> after operation]':'<filename>':_files \
  --resolve'[Resolve the host+port to this address]':'<[+]host\:port\:addr[,addr]...>' \
  {-D,--dump-header}'[Write the received headers to <filename>]':'<filename>':_files \
  {-y,--speed-time}'[Trigger '\''speed-limit'\'' abort after this time]':'<seconds>' \
  --abstract-unix-socket'[Connect via abstract Unix domain socket]':'<path>':_files \
  --proxy-cacert'[CA certificate to verify peer against for proxy]':'<file>':_files \
  --happy-eyeballs-timeout-ms'[Time for IPv6 before trying IPv4]':'<milliseconds>' \
  --proxy-ssl-auto-client-cert'[Use auto client certificate for proxy (Schannel)]' \
  {-E,--cert}'[Client certificate file and password]':'<certificate[\:password]>' \
  --connect-timeout'[Maximum time allowed for connection]':'<fractional seconds>' \
  --etag-save'[Parse ETag from a request and save it to a file]':'<file>':_files \
  --libcurl'[Dump libcurl equivalent code of this command line]':'<file>':_files \
  --proxy-pinnedpubkey'[FILE/HASHES public key to verify proxy with]':'<hashes>' \
  --doh-cert-status'[Verify the status of the DoH server cert via OCSP-staple]' \
  --etag-compare'[Pass an ETag from a file as a custom header]':'<file>':_files \
  --curves'[(EC) TLS key exchange algorithm(s) to request]':'<algorithm list>' \
  --proxy-negotiate'[Use HTTP Negotiate (SPNEGO) authentication on the proxy]' \
  --hostpubsha256'[Acceptable SHA256 hash of the host public key]':'<sha256>' \
  --mail-rcpt-allowfails'[Allow RCPT TO command to fail for some recipients]' \
  {-m,--max-time}'[Maximum time allowed for transfer]':'<fractional seconds>' \
  --socks5-hostname'[SOCKS5 proxy, pass host name to proxy]':'<host[\:port]>' \
  --pinnedpubkey'[FILE/HASHES Public key to verify peer against]':'<hashes>' \
  --proxy-insecure'[Do HTTPS proxy connections without verifying the proxy]' \
  --proxy-pass'[Pass phrase for the private key for HTTPS proxy]':'<phrase>' \
  --proxy-ssl-allow-beast'[Allow security flaw for interop for HTTPS proxy]' \
  {-p,--proxytunnel}'[Operate through an HTTP proxy tunnel (using CONNECT)]' \
  --ftp-method'[Control CWD usage]':'<method>':'(multicwd nocwd singlecwd)' \
  --proto-default'[Use PROTOCOL for any URL missing a scheme]':'<protocol>' \
  --proxy-tls13-ciphers'[TLS 1.3 proxy cipher suites]':'<ciphersuite list>' \
  --socks5-gssapi-service'[SOCKS5 proxy service name for GSS-API]':'<name>' \
  --capath'[CA directory to verify peer against]':'<dir>':'_path_files -/' \
  --ftp-alternative-to-user'[String to replace USER \[name\]]':'<command>' \
  --unix-socket'[Connect through this Unix domain socket]':'<path>':_files \
  {-T,--upload-file}'[Transfer local FILE to destination]':'<file>':_files \
  --form-escape'[Escape multipart form field/file names using backslash]' \
  --local-port'[Force use of RANGE for local port numbers]':'<num/range>' \
  --proxy-tlsauthtype'[TLS authentication type for HTTPS proxy]':'<type>' \
  {-R,--remote-time}'[Set the remote file'\''s time on the local output]' \
  --request-target'[Specify the target for this request]':'<path>':_files \
  --ssl-revoke-best-effort'[Ignore missing/offline cert CRL dist points]' \
  --ftp-ssl-control'[Require SSL/TLS for FTP login, clear for transfer]' \
  --parallel-immediate'[Do not wait for multiplexing (with --parallel)]' \
  --alt-svc'[Enable alt-svc with this cache file]':'<file name>':_files \
  --cert-status'[Verify the status of the server cert via OCSP-staple]' \
  --proxy-cert-type'[Client certificate type for HTTPS proxy]':'<type>' \
  {-Q,--quote}'[Send command(s) to server before transfer]':'<command>' \
  {-O,--remote-name}'[Write output to a file named as the remote file]' \
  --retry-connrefused'[Retry on connection refused (use with --retry)]' \
  --sasl-authzid'[Identity for SASL PLAIN authentication]':'<identity>' \
  --suppress-connect-headers'[Suppress proxy CONNECT response headers]' \
  --trace-ascii'[Like --trace, but without hex output]':'<file>':_files \
  --expect100-timeout'[How long to wait for 100-continue]':'<seconds>' \
  {-g,--globoff}'[Disable URL sequences and ranges using {} and \[\]]' \
  {-j,--junk-session-cookies}'[Ignore session cookies read from file]' \
  --parallel-max'[Maximum concurrency for parallel transfers]':'<num>' \
  --tls13-ciphers'[TLS 1.3 cipher suites to use]':'<ciphersuite list>' \
  --dns-ipv4-addr'[IPv4 address to use for DNS requests]':'<address>' \
  --dns-ipv6-addr'[IPv6 address to use for DNS requests]':'<address>' \
  --location-trusted'[Like --location, and send auth to other hosts]' \
  --mail-auth'[Originator address of the original email]':'<address>' \
  --noproxy'[List of hosts which do not use proxy]':'<no-proxy-list>' \
  --output-dir'[Directory to save files in]':'<dir>':'_path_files -/' \
  --proto-redir'[Enable/disable PROTOCOLS on redirect]':'<protocols>' \
  --proxy-cert'[Set client certificate for proxy]':'<cert[\:passwd]>' \
  --dns-interface'[Interface to use for DNS requests]':'<interface>' \
  --hostpubmd5'[Acceptable MD5 hash of the host public key]':'<md5>' \
  --keepalive-time'[Interval time for keepalive probes]':'<seconds>' \
  --random-file'[File for reading random data from]':'<file>':_files \
  --socks5-basic'[Enable username/password auth for SOCKS5 proxies]' \
  --cacert'[CA certificate to verify peer against]':'<file>':_files \
  {-H,--header}'[Pass custom header(s) to server]':'<header/@file>' \
  --ignore-content-length'[Ignore the size of the remote resource]' \
  {-i,--include}'[Include protocol response headers in the output]' \
  --preproxy'[\[protocol\://\]host\[\:port\] Use this proxy first]' \
  --proxy-header'[Pass custom header(s) to proxy]':'<header/@file>' \
  {-w,--write-out}'[Use output FORMAT after completion]':'<format>' \
  {-b,--cookie}'[Send cookies from string/file]':'<data|filename>' \
  {-o,--output}'[Write to file instead of stdout]':'<file>':_files \
  --rate'[Request rate for serial transfers]':'<max request rate>' \
  --socks4a'[SOCKS4a proxy on given host + port]':'<host[\:port]>' \
  --ssl-auto-client-cert'[Use auto client certificate (Schannel)]' \
  --hsts'[Enable HSTS with this cache file]':'<file name>':_files \
  {-U,--proxy-user}'[Proxy user and password]':'<user\:password>' \
  --proxy1.0'[Use HTTP/1.0 proxy on given port]':'<host[\:port]>' \
  {-Y,--speed-limit}'[Stop transfers slower than this]':'<speed>' \
  {-z,--time-cond}'[Transfer based on a time condition]':'<time>' \
  --connect-to'[Connect to host]':'<HOST1\:PORT1\:HOST2\:PORT2>' \
  --http2-prior-knowledge'[Use HTTP 2 without HTTP/1.1 Upgrade]' \
  --proxy-tlspassword'[TLS password for HTTPS proxy]':'<string>' \
  {-r,--range}'[Retrieve only the bytes within RANGE]':'<range>' \
  --socks4'[SOCKS4 proxy on given host + port]':'<host[\:port]>' \
  --socks5'[SOCKS5 proxy on given host + port]':'<host[\:port]>' \
  {-A,--user-agent}'[Send User-Agent <name> to server]':'<name>' \
  --egd-file'[EGD socket path for random data]':'<file>':_files \
  --fail-early'[Fail on first transfer error, do not continue]' \
  {-x,--proxy}'[\[protocol\://\]host\[\:port\] Use this proxy]' \
  {-J,--remote-header-name}'[Use the header-provided filename]' \
  --retry-max-time'[Retry only within this period]':'<seconds>' \
  {-:,--next}'[Make next URL use its separate set of options]' \
  --proxy-key-type'[Private key file type for proxy]':'<type>' \
  --retry'[Retry request if transient problems occur]':'<num>' \
  --ssl-no-revoke'[Disable cert revocation checks (Schannel)]' \
  --create-dirs'[Create necessary local directory hierarchy]' \
  --haproxy-protocol'[Send HAProxy PROXY protocol v1 header]' \
  --max-redirs'[Maximum number of redirects allowed]':'<num>' \
  {-n,--netrc}'[Must read .netrc for user name and password]' \
  --proxy-crlfile'[Set a CRL list for proxy]':'<file>':_files \
  --sasl-ir'[Enable initial response in SASL authentication]' \
  --socks5-gssapi-nec'[Compatibility with NEC SOCKS5 server]' \
  --ssl-allow-beast'[Allow security flaw to improve interop]' \
  --cert-type'[Certificate type (DER/PEM/ENG/P12)]':'<type>' \
  --create-file-mode'[File mode for created files]':'<mode>' \
  --ftp-create-dirs'[Create the remote dirs if not present]' \
  --interface'[Use network INTERFACE (or address)]':'<name>' \
  --key-type'[Private key file type (DER/PEM/ENG)]':'<type>' \
  --netrc-file'[Specify FILE for netrc]':'<filename>':_files \
  {-N,--no-buffer}'[Disable buffering of the output stream]' \
  --proxy-service-name'[SPNEGO proxy service name]':'<name>' \
  --remote-name-all'[Use the remote file name for all URLs]' \
  {-u,--user}'[Server user and password]':'<user\:password>' \
  --fail-with-body'[Fail on HTTP errors but save the body]' \
  --max-filesize'[Maximum file size to download]':'<bytes>' \
  --negotiate'[Use HTTP Negotiate (SPNEGO) authentication]' \
  --no-clobber'[Do not overwrite files that already exist]' \
  --no-keepalive'[Disable TCP keepalive on the connection]' \
  {-#,--progress-bar}'[Display transfer progress as a bar]' \
  --retry-all-errors'[Retry all errors (use with --retry)]' \
  --socks5-gssapi'[Enable GSS-API auth for SOCKS5 proxies]' \
  {-K,--config}'[Read config from a file]':'<file>':_files \
  {-C,--continue-at}'[Resumed transfer offset]':'<offset>' \
  --data-raw'[HTTP POST data, '\''@'\'' allowed]':'<data>' \
  --krb'[Enable Kerberos with security <level>]':'<level>' \
  --proxy-ciphers'[SSL ciphers to use for proxy]':'<list>' \
  --proxy-digest'[Use Digest authentication on the proxy]' \
  --proxy-tlsuser'[TLS username for HTTPS proxy]':'<name>' \
  --styled-output'[Enable styled output for HTTP headers]' \
  --tls-max'[Set maximum allowed TLS version]':'<VERSION>' \
  --data-urlencode'[HTTP POST data URL encoded]':'<data>' \
  --delegation'[GSS-API delegation permission]':'<LEVEL>' \
  --doh-insecure'[Allow insecure DoH server connections]' \
  {-P,--ftp-port}'[Use PORT instead of PASV]':'<address>' \
  --post301'[Do not switch to GET after following a 301]' \
  --post302'[Do not switch to GET after following a 302]' \
  --post303'[Do not switch to GET after following a 303]' \
  --proxy-anyauth'[Pick any proxy authentication method]' \
  --trace-time'[Add time stamps to trace/verbose output]' \
  --disallow-username-in-url'[Disallow username in URL]' \
  --dns-servers'[DNS server addrs to use]':'<addresses>' \
  --doh-url'[Resolve host names over DoH]':'<URL>':_urls \
  {-f,--fail}'[Fail fast with no output on HTTP errors]' \
  {-G,--get}'[Put the post data in the URL and use GET]' \
  --limit-rate'[Limit transfer speed to RATE]':'<speed>' \
  --ntlm-wb'[Use HTTP NTLM authentication with winbind]' \
  --path-as-is'[Do not squash .. sequences in URL path]' \
  --proxy-basic'[Use Basic authentication on the proxy]' \
  --retry-delay'[Wait time between retries]':'<seconds>' \
  --trace'[Write a debug trace to FILE]':'<file>':_files \
  {-a,--append}'[Append to target file when uploading]' \
  --ftp-ssl-ccc-mode'[Set CCC mode]':'<active/passive>' \
  --metalink'[Process given URLs as metalink XML file]' \
  --no-progress-meter'[Do not show the progress meter]' \
  --tr-encoding'[Request compressed transfer encoding]' \
  --xattr'[Store metadata in extended file attributes]' \
  {-k,--insecure}'[Allow insecure server connections]' \
  --pass'[Pass phrase for the private key]':'<phrase>' \
  --proxy-ntlm'[Use NTLM authentication on the proxy]' \
  {-S,--show-error}'[Show error even when -s is used]' \
  --stderr'[Where to redirect stderr]':'<file>':_files \
  --ciphers'[SSL ciphers to use]':'<list of ciphers>' \
  --form-string'[Specify multipart MIME data]':'<name=string>' \
  --login-options'[Server login options]':'<options>' \
  --tftp-blksize'[Set TFTP BLKSIZE option]':'<value>' \
  {-v,--verbose}'[Make the operation more talkative]' \
  --ftp-skip-pasv-ip'[Skip the IP address for PASV]' \
  --proxy-key'[Private key for HTTPS proxy]':'<key>' \
  {-F,--form}'[Specify multipart MIME data]':'<name=content>' \
  {-h,--help}'[Get help for commands]':'<category>' \
  --mail-from'[Mail from this address]':'<address>' \
  --oauth2-bearer'[OAuth 2 Bearer Token]':'<token>' \
  --proto'[Enable/disable PROTOCOLS]':'<protocols>' \
  --remove-on-error'[Remove output file on errors]' \
  --tftp-no-options'[Do not send any TFTP options]' \
  --tlsauthtype'[TLS authentication type]':'<type>' \
  --no-sessionid'[Disable SSL session-ID reusing]' \
  {-Z,--parallel}'[Perform transfers in parallel]' \
  --data-binary'[HTTP POST binary data]':'<data>' \
  --mail-rcpt'[Mail to this address]':'<address>' \
  {-t,--telnet-option}'[Set telnet option]':'<opt=val>' \
  --crlfile'[Use this CRL list]':'<file>':_files \
  --ftp-ssl-ccc'[Send CCC after authenticating]' \
  {-4,--ipv4}'[Resolve names to IPv4 addresses]' \
  {-6,--ipv6}'[Resolve names to IPv6 addresses]' \
  --service-name'[SPNEGO service name]':'<name>' \
  {-V,--version}'[Show version number and quit]' \
  --data-ascii'[HTTP POST ASCII data]':'<data>' \
  --ftp-account'[Account data string]':'<data>' \
  --disable-eprt'[Inhibit using EPRT or LPRT]' \
  --netrc-optional'[Use either .netrc or URL]' \
  --proxy-http2'[Use HTTP/2 with HTTPS proxy]' \
  --pubkey'[SSH Public key file name]':'<key>' \
  --raw'[Do HTTP "raw"; no transfer decoding]' \
  {-e,--referer}'[Referrer URL]':'<URL>':_urls \
  --url-query'[Add a URL query part]':'<data>' \
  --anyauth'[Pick any authentication method]' \
  --compressed'[Request compressed response]' \
  --ftp-pasv'[Use PASV/EPSV instead of PORT]' \
  --no-alpn'[Disable the ALPN TLS extension]' \
  --tcp-nodelay'[Use the TCP_NODELAY option]' \
  {-B,--use-ascii}'[Use ASCII/text transfer]' \
  --compressed-ssh'[Enable SSH compression]' \
  --digest'[Use HTTP Digest Authentication]' \
  --proxy-tlsv1'[Use TLSv1 for HTTPS proxy]' \
  --engine'[Crypto engine to use]':'<name>' \
  --no-npn'[Disable the NPN TLS extension]' \
  --basic'[Use HTTP Basic Authentication]' \
  {-M,--manual}'[Display the full manual]' \
  --tlspassword'[TLS password]':'<string>' \
  --false-start'[Enable TLS False Start]' \
  --url'[URL to work with]':'<url>':_urls \
  --crlf'[Convert LF to CRLF in upload]' \
  {-d,--data}'[HTTP POST data]':'<data>' \
  {-I,--head}'[Show document info only]' \
  --key'[Private key file name]':'<key>' \
  --ntlm'[Use HTTP NTLM authentication]' \
  {-1,--tlsv1}'[Use TLSv1.0 or greater]' \
  --http0.9'[Allow HTTP 0.9 responses]' \
  --disable-epsv'[Inhibit using EPSV]' \
  --ftp-pret'[Send PRET before PASV]' \
  {-L,--location}'[Follow redirects]' \
  --tcp-fastopen'[Use TCP Fast Open]' \
  --tlsuser'[TLS user name]':'<name>' \
  --tlsv1.0'[Use TLSv1.0 or greater]' \
  --tlsv1.1'[Use TLSv1.1 or greater]' \
  --tlsv1.2'[Use TLSv1.2 or greater]' \
  --tlsv1.3'[Use TLSv1.3 or greater]' \
  {-l,--list-only}'[List only mode]' \
  {-q,--disable}'[Disable .curlrc]' \
  --json'[HTTP POST JSON]':'<data>' \
  --http3-only'[Use HTTP v3 only]' \
  {-0,--http1.0}'[Use HTTP 1.0]' \
  --ssl-reqd'[Require SSL/TLS]' \
  {-s,--silent}'[Silent mode]' \
  --http1.1'[Use HTTP 1.1]' \
  {-2,--sslv2}'[Use SSLv2]' \
  {-3,--sslv3}'[Use SSLv3]' \
  --http3'[Use HTTP v3]' \
  --http2'[Use HTTP 2]' \
  --ssl'[Try SSL/TLS]' \
  '*:URL:_urls' && rc=0

return rc
