#compdef curl

# curl zsh completion

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

local rc=1

_arguments -C -S \
  {-Y,--speed-limit}'[Stop transfers below speed-limit for '\''speed-time'\'' secs]':RATE \
  {-c,--cookie-jar}'[Write cookies to this file after operation (H)]':FILE:_files \
  {-S,--show-error}'[Show error. With -s, make curl show errors when they occur]' \
  {-y,--speed-time}'[Time for trig speed-limit abort. Defaults to 30]':SECONDS \
  --retry-delay'[When retrying, wait this many seconds between each]':SECONDS \
  --ftp-alternative-to-user'[String to replace "USER \[name\]" (F)]':COMMAND \
  --ftp-ssl-control'[SSL/TLS for ftp login, clear for transfer (F)]':Require \
  --libcurl'[Dump libcurl equivalent code of this command line]':FILE:_files \
  --crlfile'[Get a CRL list in PEM format from the given file]':FILE:_files \
  --proto-redir'[Enable/disable specified protocols on redirect]':PROTOCOLS \
  {-p,--proxytunnel}'[Operate through a HTTP proxy tunnel (using CONNECT)]' \
  --hostpubmd5'[Hex encoded MD5 string of the host public key. (SSH)]':MD5 \
  {-j,--junk-session-cookies}'[session cookies read from file (H)]':Ignore \
  {-E,--cert}'[Client certificate file and password (SSL)]':CERT[:PASSWD] \
  {-R,--remote-time}'[Set the remote file'\''s time on the local output]' \
  {-P,--ftp-port}'[Use PORT with given address instead of PASV (F)]':ADR \
  --location-trusted'[--location and send auth to other hosts (H)]':like \
  {-Q,--quote}'[Send command(s) to server before transfer (F/SFTP)]':CMD \
  --socks5-hostname'[SOCKS5 proxy, pass host name to proxy]':HOST[:PORT] \
  {-o,--output}'[Write output to <file> instead of stdout]':FILE:_files \
  {-O,--remote-name}'[Write output to a file named as the remote file]' \
  {-b,--cookie}'[String or file to read cookies from (H)]':STRING/FILE \
  {-g,--globoff}'[Disable URL sequences and ranges using {} and \[\]]' \
  --post301'[Do not switch to GET after following a 301 redirect (H)]' \
  --post302'[Do not switch to GET after following a 302 redirect (H)]' \
  --post303'[Do not switch to GET after following a 303 redirect (H)]' \
  --random-file'[File for reading random data from (SSL)]':FILE:_files \
  --resolve'[Force resolve of HOST:PORT to ADDRESS]':HOST:PORT:ADDRESS \
  --socks5-gssapi-service'[SOCKS5 proxy service name for gssapi]':NAME \
  --trace-ascii'[Like --trace but without the hex output]':FILE:_files \
  --cacert'[CA certificate to verify peer against (SSL)]':FILE:_files \
  --compressed'[Request compressed response (using deflate or gzip)]' \
  {-k,--insecure}'[Allow connections to SSL sites without certs (H)]' \
  {-f,--fail}'[Fail silently (no output at all) on HTTP errors (H)]' \
  {-#,--progress-bar}'[Display transfer progress as a progress bar]' \
  --proxy-negotiate'[Negotiate authentication on the proxy (H)]':Use \
  --retry'[Retry request NUM times if transient problems occur]':NUM \
  --engine'[Crypto engine (SSL). "--engine list" for list]':ENGINGE \
  --interface'[Specify network interface/address to use]':INTERFACE \
  {-J,--remote-header-name}'[the header-provided filename (H)]':Use \
  --ssl-allow-beast'[security flaw to improve interop (SSL)]':Allow \
  --capath'[CA directory to verify peer against (SSL)]':DIR:_files \
  --connect-timeout'[Maximum time allowed for connection]':SECONDS \
  {-D,--dump-header}'[Write the headers to this file]':FILE:_files \
  --ftp-method'[Control CWD usage (F)]':[MULTICWD/NOCWD/SINGLECWD] \
  --ignore-content-length'[Ignore the HTTP Content-Length header]' \
  --krb'[Enable Kerberos with specified security level (F)]':LEVEL \
  {-m,--max-time}'[Maximum time allowed for the transfer]':SECONDS \
  {-x,--proxy}'[Use proxy on given port]':[PROTOCOL://]HOST[:PORT] \
  --stderr'[Where to redirect stderr. - means stdout]':FILE:_files \
  --egd-file'[EGD socket path for random data (SSL)]':FILE:_files \
  {-a,--append}'[Append to target file when uploading (F/SFTP)]' \
  {-K,--config}'[Specify which config file to read]':FILE:_files \
  --ftp-create-dirs'[Create the remote dirs if not present (F)]' \
  {-i,--include}'[Include protocol headers in the output (H/F)]' \
  --tftp-blksize'[Set TFTP BLKSIZE option (must be >512)]':VALUE \
  {-T,--upload-file}'[Transfer FILE to destination]':FILE:_files \
  --cert-type'[Certificate file type (DER/PEM/ENG) (SSL)]':TYPE \
  --keepalive-time'[Interval between keepalive probes]':SECONDS \
  --proxy-anyauth'["any" proxy authentication method (H)]':Pick \
  --tlsauthtype'[TLS authentication type (default SRP)]':STRING \
  --form-string'[Specify HTTP multipart POST data (H)]':STRING \
  --key-type'[Private key file type (DER/PEM/ENG) (SSL)]':TYPE \
  --mail-auth'[Originator address of the original email]':AUTH \
  --netrc-file'[Set up the netrc filename to use]':FILE:_files \
  --proxy-digest'[Use Digest authentication on the proxy (H)]' \
  {-U,--proxy-user}'[Proxy user and password]':USER[:PASSWORD] \
  {-r,--range}'[Retrieve only the bytes within a range]':RANGE \
  --trace'[Write a debug trace to the given file]':FILE:_files \
  {-A,--user-agent}'[User-Agent to send to server (H)]':STRING \
  --create-dirs'[Create necessary local directory hierarchy]' \
  {-F,--form}'[Specify HTTP multipart POST data (H)]':CONTENT \
  {-l,--list-only}'[List only names of an FTP directory (F)]' \
  --local-port'[Force use of these local port numbers]':RANGE \
  --max-filesize'[Maximum file size to download (H/F)]':BYTES \
  --max-redirs'[Maximum number of redirects allowed (H)]':NUM \
  {-n,--netrc}'[Must read .netrc for user name and password]' \
  --socks4a'[SOCKS4a proxy on given host + port]':HOST[:PORT] \
  --socks5-gssapi-nec'[Compatibility with NEC SOCKS5 server]' \
  {-z,--time-cond}'[Transfer based on a time condition]':TIME \
  --netrc-optional'[either .netrc or URL; overrides -n]':Use \
  {-N,--no-buffer}'[Disable buffering of the output stream]' \
  --proxy-basic'[Use Basic authentication on the proxy (H)]' \
  --proxy1.0'[Use HTTP/1.0 proxy on given port]':HOST[:PORT] \
  --remote-name-all'[the remote file name for all URLs]':Use \
  {-w,--write-out}'[What to output after completion]':FORMAT \
  {-H,--header}'[Custom header to pass to server (H)]':LINE \
  --no-keepalive'[Disable keepalive use on the connection]' \
  --raw'[Do HTTP "raw", without any transfer decoding (H)]' \
  --retry-max-time'[Retry only within this period]':SECONDS \
  --socks4'[SOCKS4 proxy on given host + port]':HOST[:PORT] \
  --socks5'[SOCKS5 proxy on given host + port]':HOST[:PORT] \
  --tr-encoding'[Request compressed transfer encoding (H)]' \
  --pass'[Pass phrase for the private key (SSL/SSH)]':PASS \
  --proxy-ntlm'[Use NTLM authentication on the proxy (H)]' \
  {-X,--request}'[Specify request command to use]':COMMAND \
  --data-urlencode'[HTTP POST data url encoded (H)]':DATA \
  --proto'[Enable/disable specified protocols]':PROTOCOLS \
  --trace-time'[Add time stamps to trace/verbose output]' \
  {-u,--user}'[Server user and password]':USER[:PASSWORD] \
  --ftp-skip-pasv-ip'[the IP address for PASV (F)]':Skip \
  --limit-rate'[Limit transfer speed to this rate]':RATE \
  --no-sessionid'[Disable SSL session-ID reusing (SSL)]' \
  {-s,--silent}'[Silent mode. Don'\''t output anything]' \
  --ftp-ssl-ccc-mode'[Set CCC mode (F)]':ACTIVE/PASSIVE \
  --ssl-reqd'[Require SSL/TLS (FTP, IMAP, POP3, SMTP)]' \
  --xattr'[Store metadata in extended file attributes]' \
  {-C,--continue-at}'[Resumed transfer offset]':OFFSET \
  --delegation'[GSS-API delegation permission]':STRING \
  --ftp-pret'[Send PRET before PASV (for drftpd) (F)]' \
  --negotiate'[Use HTTP Negotiate Authentication (H)]' \
  {-v,--verbose}'[Make the operation more talkative]' \
  --ftp-ssl-ccc'[Send CCC after authenticating (F)]' \
  {-G,--get}'[Send the -d data with a HTTP GET (H)]' \
  --anyauth'[Pick "any" authentication method (H)]' \
  --noproxy'[List of hosts which do not use proxy]' \
  --disable-eprt'[Inhibit using EPRT or LPRT (F)]' \
  --data-binary'[HTTP POST binary data (H)]':DATA \
  --ftp-pasv'[Use PASV/EPSV instead of PORT (F)]' \
  --digest'[Use HTTP Digest Authentication (H)]' \
  {-V,--version}'[Show version number and quit]' \
  --data-ascii'[HTTP POST ASCII data (H)]':DATA \
  --ftp-account'[Account data string (F)]':DATA \
  {-t,--telnet-option}'[Set telnet option]':OPT=VAL \
  --basic'[Use HTTP Basic Authentication (H)]' \
  --key'[Private key file name (SSL/SSH)]':KEY \
  --ssl'[Try SSL/TLS (FTP, IMAP, POP3, SMTP)]' \
  {-4,--ipv4}'[Resolve name to IPv4 address]' \
  {-6,--ipv6}'[Resolve name to IPv6 address]' \
  --tcp-nodelay'[Use the TCP_NODELAY option]' \
  {-B,--use-ascii}'[Use ASCII/text transfer]' \
  --ciphers'[SSL ciphers to use (SSL)]':LIST \
  --mail-from'[Mail from this address]':FROM \
  --mail-rcpt'[Mail to this receiver(s)]':TO \
  --ntlm'[Use HTTP NTLM authentication (H)]' \
  --pubkey'[Public key file name (SSH)]':KEY \
  --disable-epsv'[Inhibit using EPSV (F)]' \
  {-M,--manual}'[Display the full manual]' \
  {-L,--location}'[Follow redirects (H)]' \
  --crlf'[Convert LF to CRLF in upload]' \
  {-d,--data}'[HTTP POST data (H)]':DATA \
  {-I,--head}'[Show document info only]' \
  --tlspassword'[TLS password]':STRING \
  {-0,--http1.0}'[Use HTTP 1.0 (H)]' \
  {-e,--referer}'[Referer URL (H)]' \
  {-2,--sslv2}'[Use SSLv2 (SSL)]' \
  {-3,--sslv3}'[Use SSLv3 (SSL)]' \
  {-1,--tlsv1}'[Use TLSv1 (SSL)]' \
  --tlsuser'[TLS username]':USER \
  {-h,--help}'[This help text]' \
  --url'[URL to work with]':URL \
  '*:URL:_urls' && rc=0

return rc
