[Bash-completion-devel] wget(1) completion
Raphaël Droz
raphael.droz+floss at gmail.com
Sun Dec 4 18:49:01 UTC 2011
back with this one
[ http://lists.alioth.debian.org/pipermail/bash-completion-devel/2009-March/001088.html ]
Raph
-------------- next part --------------
proc setup {} {
save_env
}
proc teardown {} {
assert_env_unmodified
}
setup
assert_complete_any "wget --"
sync_after_int
teardown
-------------- next part --------------
5874087 Various enhancements for wget(1) completion
diff --git a/bash_completion b/bash_completion
index 00f72f9..4cfd97f 100644
--- a/bash_completion
+++ b/bash_completion
@@ -1758,7 +1758,7 @@ complete -F _longopt a2ps awk base64 bash bc bison cat colordiff cp csplit \
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 \
- texindex touch tr uname unexpand uniq units vdir wc wget who
+ texindex touch tr uname unexpand uniq units vdir wc who
declare -A _xspecs
_filedir_xspec()
-------------- next part --------------
# wget(1) completion -*- shell-script -*-
_wget() {
local cur prev words cword split
_init_completion -s || return
case $prev in
--progress)
COMPREPLY=( $( compgen -W 'bar dot' -- $cur ) )
return 0
;;
-D|-@(bind-address|@(exclude-|)domains))
_known_hosts_real
return 0
;;
--restrict-file-names)
local excludes=()
[[ $cur =~ (unix|windows), ]] && excludes=( windows unix )
[[ $cur =~ (low|upp)ercase, ]] && excludes+=( lowercase uppercase )
[[ $cur =~ nocontrol ]] && excludes+=( nocontrol )
[[ $cur =~ ascii ]] && excludes+=( ascii )
# prevopt is the previous options string used as a prefix
# to avoid COMPREPLY replacing them with the $lastopt completion
local lastopt=${cur/*,} prevopt=
[[ ${cur} =~ , ]] && prevopt=${cur%,*},
local excludes_str=$( export IFS='|'; echo "${excludes[*]}"; )
COMPREPLY=( $( compgen -P "${prevopt}" -X "@($excludes_str)" \
-W 'unix windows nocontrol ascii lowercase uppercase' \
-- $lastopt ) )
# +o nospace when no more valid option is possible (= append a space)
local opt_as_arr=( $(echo ${COMPREPLY[0]//,/ }) )
[[ ${#opt_as_arr[@]} -lt 4 ]] && compopt -o nospace
return 0
;;
--prefer-family)
COMPREPLY=( $( compgen -W 'IPv4 IPv6 none' -- $cur ) )
return 0
;;
-P|--directory-prefix|--ca-directory)
_filedir -d
return 0
;;
-a|--append-output|--load-cookies|--post-file|--@(ca-|)certificate|--private-key|--random-file|--egd-file)
_filedir
return 0
;;
-o|--output-file|-O|--output-document|--save-cookies|--default-page)
# these options specify a file which may or may not be overwriten
# _filedir
[[ $prev =~ -O|--output-document && ( $cur = -* || -z $cur ) ]] && COMPREPLY+=( - )
return 0;
;;
-i|--input-file)
# adds the standard input/output to the possibilities
_filedir && [[ $cur = -* || -z $cur ]] && COMPREPLY+=( - )
return 0
;;
--secure-protocol)
COMPREPLY=( $( compgen -W 'auto SSLv2 SSLv3 TLSv1' -- $cur ) )
return 0
;;
--@(certificate|private-key)-type)
COMPREPLY=( $( compgen -W 'PEM DER' -- $cur ) )
return 0
;;
--@(follow|ignore)-tags)
local lastopt=${cur/*,} prevopt=
[[ ${cur} =~ , ]] && prevopt=${cur%,*},
COMPREPLY=( $( compgen -P "${prevopt}"
-W 'a abbr acronym address applet area b base basefont bdo big blockquote
body br button caption center cite code col colgroup dd del dir div dfn dl dt em fieldset
font form frame frameset h6 head hr html i iframe img input ins isindex kbd label legend
li link map menu meta noframes noscript object ol optgroup option p param pre q s samp
script select small span strike strong style sub sup table tbody td textarea tfoot th
thead title tr tt u ul var xmp' -- $lastopt ) )
return 0
;;
--tries|--@(dns-|connect-|)timeout|--limit-rate|--wait|--waitretry|--cut-dirs|--max-redirect)
COMPREPLY=( $( compgen -W "{0..9}" -- $cur ) )
return 0
;;
--quota)
COMPREPLY=( $( compgen -W "{0..9}{k,m}" -- $cur ) )
return 0
;;
--@(http-|proxy-|ftp-|)user)
COMPREPLY=( $( compgen -W "$(sed -n '/^login/s/^[[:blank:]]*login[[:blank:]]//p' ~/.netrc)" -- $cur ) )
return 0
;;
--level)
COMPREPLY=( $( compgen -W "{1..5}" -- $cur ) )
return 0
;;
--header)
COMPREPLY=( $( compgen -W 'Accept Accept-Charset Accept-Encoding Accept-Language
Accept-Ranges Age Allow Authorization Cache-Control Connection Content-Encoding
Content-Language Content-Length Content-Location Content-MD5 Content-Range
Content-Type Date ETag Expect Expires From Host If-Match If-Modified-Since
If-None-Match If-Range If-Unmodified-Since Last-Modified Location Max-Forwards
Pragma Proxy-Authenticate Proxy-Authorization Range Referer Retry-After
Server TE Trailer Transfer-Encoding Upgrade User-Agent Vary Via Warning
WWW-Authenticate' -- $cur ) )
return 0
;;
--@(local|remote)-encoding)
: # TODO
;;
--execute)
: # TODO: base=STR
;;
esac
case $cur in
--*)
COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) )
[[ $COMPREPLY == *= ]] && compopt -o nospace
;;
# only complete long options
-)
compopt -o nospace
COMPREPLY=( -- )
;;
esac
return 0
} &&
complete -F _wget wget
# 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
More information about the Bash-completion-devel
mailing list