summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVille Skyttä <ville.skytta@iki.fi>2011-07-12 00:07:35 +0300
committerVille Skyttä <ville.skytta@iki.fi>2011-07-12 00:07:35 +0300
commitb68cc0057f605fefcba540fef993ec72a4ee2407 (patch)
tree55a80352b398eebd1706a89731fe178485187bd5
parent1daff31f2efb33412ab5d3f27f4d5681d9ac6568 (diff)
downloadbash-completion-b68cc0057f605fefcba540fef993ec72a4ee2407.tar.gz
curl: New non-generic completion.
-rw-r--r--bash_completion2
-rw-r--r--completions/Makefile.am1
-rw-r--r--completions/curl91
-rw-r--r--test/completion/curl.exp1
-rw-r--r--test/lib/completions/curl.exp20
5 files changed, 114 insertions, 1 deletions
diff --git a/bash_completion b/bash_completion
index 6c3cd736..6297bb8b 100644
--- a/bash_completion
+++ b/bash_completion
@@ -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 \
diff --git a/completions/Makefile.am b/completions/Makefile.am
index b009fbc9..dce9047c 100644
--- a/completions/Makefile.am
+++ b/completions/Makefile.am
@@ -30,6 +30,7 @@ bashcomp_DATA = abook \
cppcheck \
crontab \
cups \
+ curl \
cryptsetup \
cvs \
cvsps \
diff --git a/completions/curl b/completions/curl
new file mode 100644
index 00000000..1fb96d69
--- /dev/null
+++ b/completions/curl
@@ -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
diff --git a/test/completion/curl.exp b/test/completion/curl.exp
new file mode 100644
index 00000000..e8bf2135
--- /dev/null
+++ b/test/completion/curl.exp
@@ -0,0 +1 @@
+assert_source_completions curl
diff --git a/test/lib/completions/curl.exp b/test/lib/completions/curl.exp
new file mode 100644
index 00000000..53512bc4
--- /dev/null
+++ b/test/lib/completions/curl.exp
@@ -0,0 +1,20 @@
+proc setup {} {
+ save_env
+}
+
+
+proc teardown {} {
+ assert_env_unmodified
+}
+
+
+setup
+
+
+assert_complete_any "curl -"
+
+
+sync_after_int
+
+
+teardown