curl: New non-generic completion.

This commit is contained in:
Ville Skyttä 2011-07-12 00:07:35 +03:00
parent 1daff31f2e
commit b68cc0057f
5 changed files with 114 additions and 1 deletions

View File

@ -1693,7 +1693,7 @@ _longopt()
}
# makeinfo and texi2dvi are defined elsewhere.
for i in a2ps awk bash bc bison cat colordiff cp csplit \
curl cut date df diff dir du enscript env expand fmt fold gperf gprof \
cut date df diff dir du enscript env expand fmt fold gperf gprof \
grep grub head indent irb ld ldd less ln ls m4 md5sum mkdir mkfifo mknod \
mv netstat nl nm objcopy objdump od paste patch pr ptx readelf rm rmdir \
sed seq sha{,1,224,256,384,512}sum shar sort split strip sum tac tail tee \

View File

@ -30,6 +30,7 @@ bashcomp_DATA = abook \
cppcheck \
crontab \
cups \
curl \
cryptsetup \
cvs \
cvsps \

91
completions/curl Normal file
View File

@ -0,0 +1,91 @@
have curl || return
_curl()
{
local cur prev words cword
_init_completion || return
case $prev in
--ciphers|--connect-timeout|-C|--continue-at|--form|--form-string|\
--ftp-account|--ftp-alternative-to-user|-P|--ftp-port|-H|--header|-h|\
--help|--hostpubmd5|--keepalive-time|--krb|--limit-rate|--local-port|\
--mail-from|--mail-rcpt|--max-filesize|--max-redirs|-m|--max-time|\
--pass|--proto|--proto-redir|--proxy-user|--proxy1.0|-Q|--quote|-r|\
--range|-X|--request|--retry|--retry-delay|--retry-max-time|\
--socks5-gssapi-service|-t|--telnet-option|--tftp-blksize|-z|\
--time-cond|--url|-u|--user|-A|--user-agent|-V|--version|-w|--write-out)
return
;;
-K|--config|-b|--cookie|-c|--cookie-jar|-D|--dump-header|--egd-file|\
--key|--libcurl|-o|--output|--random-file|-T|--upload-file)
_filedir
return
;;
--cacert|-E|--cert)
_filedir '@(c?(e)rt|cer|pem|der)'
return
;;
--capath)
_filedir -d
return
;;
--cert-type|--key-type)
COMPREPLY=( $( compgen -W 'DER PEM ENG' -- "$cur" ) )
return
;;
--crlfile)
_filedir crl
return
;;
-d|--data|--data-ascii|--data-binary|--data-urlencode)
if [[ $cur == \@* ]]; then
cur=${cur:1}
_filedir
COMPREPLY=( "${COMPREPLY[@]/#/@}" )
fi
return
;;
--engine)
COMPREPLY=( $( compgen -W 'list' -- "$cur" ) )
return
;;
--ftp-method)
COMPREPLY=( $( compgen -W 'multicwd nocwd singlecwd' -- "$cur" ) )
return
;;
--ftp-ssl-ccc-mode)
COMPREPLY=( $( compgen -W 'active passive' -- "$cur" ) )
return
;;
--interface)
_available_interfaces -a
return
;;
-x|--proxy|--socks4|--socks4a|--socks5|--socks5-hostname)
_known_hosts_real
return
;;
--pubkey)
_filedir pub
return
;;
--stderr)
COMPREPLY=( $( compgen -W '-' -- "$cur" ) )
_filedir
return
;;
esac
if [[ $cur == -* ]]; then
COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) )
fi
} &&
complete -F _curl curl
# Local variables:
# mode: shell-script
# sh-basic-offset: 4
# sh-indent-comment: t
# indent-tabs-mode: nil
# End:
# ex: ts=4 sw=4 et filetype=sh

1
test/completion/curl.exp Normal file
View File

@ -0,0 +1 @@
assert_source_completions curl

View File

@ -0,0 +1,20 @@
proc setup {} {
save_env
}
proc teardown {} {
assert_env_unmodified
}
setup
assert_complete_any "curl -"
sync_after_int
teardown