Use _split_longopt in mailman.

This commit is contained in:
Ville Skyttä 2009-06-12 20:26:54 +03:00
parent 4f04c9553d
commit fb58599470
2 changed files with 83 additions and 45 deletions

View File

@ -64,9 +64,9 @@ bash-completion (1.x)
* Add _split_longopt() helper for improved handling of long options that * Add _split_longopt() helper for improved handling of long options that
take arguments in both "--foo bar" and "--foo=bar" formats. take arguments in both "--foo bar" and "--foo=bar" formats.
* Use _split_longopt to improve and clean up aspell, bluez-utils, chgrp, * Use _split_longopt to improve and clean up aspell, bluez-utils, chgrp,
chown, chkconfig, cpio, dpkg, heimdal, iptables, make, mc, mii-diag, chown, chkconfig, cpio, dpkg, heimdal, iptables, mailman, make, mc,
mii-tool, mkinitrd, pkg-config, postgresql, quota, reportbug, samba, mii-diag, mii-tool, mkinitrd, pkg-config, postgresql, quota, reportbug,
smartctl, yum, and generic long option completion (Alioth: #311398). samba, smartctl, yum, and generic long option completion (Alioth: #311398).
* Add chown --from and --reference value completions. * Add chown --from and --reference value completions.
* Add chgrp --reference value completion. * Add chgrp --reference value completion.
* Do not assume all --foo= options take filenames in generic long option * Do not assume all --foo= options take filenames in generic long option

View File

@ -29,27 +29,31 @@ complete -F _list_lists list_lists
have add_members && have add_members &&
_add_members() _add_members()
{ {
local cur prev local cur prev split=false
COMPREPLY=() COMPREPLY=()
cur=`_get_cword` cur=`_get_cword`
prev=${COMP_WORDS[COMP_CWORD-1]} prev=${COMP_WORDS[COMP_CWORD-1]}
_split_longopt && split=true
case "$prev" in case "$prev" in
-@(r|d|-regular-members-file=|-digest-members-file=)) -@(r|d|-regular-members-file|-digest-members-file))
_filedir _filedir
return 0 return 0
;; ;;
-@(w|a|-welcome-msg=|-admin-notify=)) -@(w|a|-welcome-msg|-admin-notify))
COMPREPLY=( $( compgen -W 'y n' -- $cur) ) COMPREPLY=( $( compgen -W 'y n' -- $cur) )
return 0 return 0
;; ;;
esac esac
$split && return 0
if [[ "$cur" == -* ]]; then if [[ "$cur" == -* ]]; then
COMPREPLY=( $( compgen -W '--regular-members-file= -r \ COMPREPLY=( $( compgen -W '--regular-members-file -r \
--digest-members-file= -d --welcome-msg= -w \ --digest-members-file -d --welcome-msg -w \
--admin-notify= -a --help -h' -- $cur ) ) --admin-notify -a --help -h' -- $cur ) )
else else
_mailman_lists _mailman_lists
fi fi
@ -60,22 +64,25 @@ complete -F _add_members add_members
have remove_members && have remove_members &&
_remove_members() _remove_members()
{ {
local cur prev split=false
local cur prev
COMPREPLY=() COMPREPLY=()
cur=`_get_cword` cur=`_get_cword`
prev=${COMP_WORDS[COMP_CWORD-1]} prev=${COMP_WORDS[COMP_CWORD-1]}
_split_longopt && split=true
case "$prev" in case "$prev" in
-@(f|-file=)) -@(f|-file))
_filedir _filedir
return 0 return 0
;; ;;
esac esac
$split && return 0
if [[ "$cur" == -* ]]; then if [[ "$cur" == -* ]]; then
COMPREPLY=( $( compgen -W '--file= -f --all -a \ COMPREPLY=( $( compgen -W '--file -f --all -a \
--fromall --nouserack -n --noadminack -N \ --fromall --nouserack -n --noadminack -N \
--help -h' -- $cur ) ) --help -h' -- $cur ) )
else else
@ -88,23 +95,26 @@ complete -F _remove_members remove_members
have find_member && have find_member &&
_find_member() _find_member()
{ {
local cur prev split=false
local cur prev
COMPREPLY=() COMPREPLY=()
cur=`_get_cword` cur=`_get_cword`
prev=${COMP_WORDS[COMP_CWORD-1]} prev=${COMP_WORDS[COMP_CWORD-1]}
_split_longopt && split=true
case "$prev" in case "$prev" in
-@(l|x|-listname=|-exclude=)) -@(l|x|-listname|-exclude))
_mailman_lists _mailman_lists
return 0 return 0
;; ;;
esac esac
$split && return 0
if [[ "$cur" == -* ]]; then if [[ "$cur" == -* ]]; then
COMPREPLY=( $( compgen -W '-l --listname= -x \ COMPREPLY=( $( compgen -W '-l --listname -x \
--exclude= --owners -w --help -h' -- $cur ) ) --exclude --owners -w --help -h' -- $cur ) )
fi fi
} && } &&
@ -113,22 +123,25 @@ complete -F _find_member find_member
have clone_member && have clone_member &&
_clone_member() _clone_member()
{ {
local cur prev split=false
local cur prev
COMPREPLY=() COMPREPLY=()
cur=`_get_cword` cur=`_get_cword`
prev=${COMP_WORDS[COMP_CWORD-1]} prev=${COMP_WORDS[COMP_CWORD-1]}
_split_longopt && split=true
case "$prev" in case "$prev" in
-@(l|-listname=)) -@(l|-listname))
_mailman_lists _mailman_lists
return 0 return 0
;; ;;
esac esac
$split && return 0
if [[ "$cur" == -* ]]; then if [[ "$cur" == -* ]]; then
COMPREPLY=( $( compgen -W '-l --listname= --remove -r \ COMPREPLY=( $( compgen -W '-l --listname --remove -r \
--admin -a --quiet -q --nomodify -n --help -h' -- $cur ) ) --admin -a --quiet -q --nomodify -n --help -h' -- $cur ) )
fi fi
@ -138,14 +151,16 @@ complete -F _clone_member clone_member
have sync_members && have sync_members &&
_sync_members() _sync_members()
{ {
local cur prev local cur prev split=false
COMPREPLY=() COMPREPLY=()
cur=`_get_cword` cur=`_get_cword`
prev=${COMP_WORDS[COMP_CWORD-1]} prev=${COMP_WORDS[COMP_CWORD-1]}
_split_longopt && split=true
case "$prev" in case "$prev" in
-@(w|g|d|--welcome-msg=|-goodbye-msg|-digest=)) -@(w|g|d|--welcome-msg|-goodbye-msg|-digest))
COMPREPLY=( $( compgen -W 'y n' -- $cur) ) COMPREPLY=( $( compgen -W 'y n' -- $cur) )
return 0 return 0
;; ;;
@ -155,9 +170,11 @@ _sync_members()
;; ;;
esac esac
$split && return 0
if [[ "$cur" == -* ]]; then if [[ "$cur" == -* ]]; then
COMPREPLY=( $( compgen -W '--no-change -n --welcome-msg= -w \ COMPREPLY=( $( compgen -W '--no-change -n --welcome-msg -w \
--goodbye-msg= -g --digest= -d --notifyadmin= -a \ --goodbye-msg -g --digest -d --notifyadmin -a \
-f --file -h --help' -- $cur ) ) -f --file -h --help' -- $cur ) )
else else
_mailman_lists _mailman_lists
@ -192,7 +209,7 @@ _list_admins()
cur=`_get_cword` cur=`_get_cword`
if [[ "$cur" == -* ]]; then if [[ "$cur" == -* ]]; then
COMPREPLY=( $( compgen -W '--all-vhost= -v \ COMPREPLY=( $( compgen -W '--all-vhost -v \
--all -a -h --help' -- $cur ) ) --all -a -h --help' -- $cur ) )
else else
_mailman_lists _mailman_lists
@ -222,31 +239,34 @@ complete -F _list_owners list_owners
have list_members && have list_members &&
_list_members() _list_members()
{ {
local cur prev local cur prev split=false
COMPREPLY=() COMPREPLY=()
cur=`_get_cword` cur=`_get_cword`
prev=${COMP_WORDS[COMP_CWORD-1]} prev=${COMP_WORDS[COMP_CWORD-1]}
_split_longopt && split=true
case "$prev" in case "$prev" in
-@(o|-output)) -@(o|-output))
_filedir _filedir
return 0 return 0
;; ;;
-@(d|-digest=)) -@(d|-digest))
COMPREPLY=( $( compgen -W 'mime plain' -- $cur) ) COMPREPLY=( $( compgen -W 'mime plain' -- $cur) )
return 0 return 0
;; ;;
-@(n|-nomail=)) -@(n|-nomail))
COMPREPLY=( $( compgen -W 'byadmin byuser bybounce unknown' -- $cur) ) COMPREPLY=( $( compgen -W 'byadmin byuser bybounce unknown' -- $cur) )
return 0 return 0
;; ;;
esac esac
$split && return 0
if [[ "$cur" == -* ]]; then if [[ "$cur" == -* ]]; then
COMPREPLY=( $( compgen -W '--output -o --regular -r \ COMPREPLY=( $( compgen -W '--output -o --regular -r \
--digest= -d --nomail= -n --fullnames -f \ --digest -d --nomail -n --fullnames -f \
--preserve -p -h --help' -- $cur ) ) --preserve -p -h --help' -- $cur ) )
else else
_mailman_lists _mailman_lists
@ -258,22 +278,26 @@ complete -F _list_members list_members
have change_pw && have change_pw &&
_change_pw() _change_pw()
{ {
local cur prev local cur prev split=false
COMPREPLY=() COMPREPLY=()
cur=`_get_cword` cur=`_get_cword`
prev=${COMP_WORDS[COMP_CWORD-1]} prev=${COMP_WORDS[COMP_CWORD-1]}
_split_longopt && split=true
case "$prev" in case "$prev" in
-@(l|-listname=)) -@(l|-listname))
_mailman_lists _mailman_lists
return 0 return 0
;; ;;
esac esac
$split && return 0
if [[ "$cur" == -* ]]; then if [[ "$cur" == -* ]]; then
COMPREPLY=( $( compgen -W '-a --all --domain= -d --listname= -l \ COMPREPLY=( $( compgen -W '-a --all --domain -d --listname -l \
--password= -p --quiet -q -h --help' -- $cur ) ) --password -p --quiet -q -h --help' -- $cur ) )
fi fi
} && } &&
@ -335,11 +359,13 @@ complete -F _rmlist rmlist
have config_list && have config_list &&
_config_list() _config_list()
{ {
local cur prev local cur prev split=false
COMPREPLY=() COMPREPLY=()
cur=`_get_cword` cur=`_get_cword`
prev=${COMP_WORDS[COMP_CWORD-1]} prev=${COMP_WORDS[COMP_CWORD-1]}
_split_longopt && split=true
case "$prev" in case "$prev" in
-@(i|o|-inputfile|-outputfile)) -@(i|o|-inputfile|-outputfile))
@ -348,6 +374,7 @@ _config_list()
;; ;;
esac esac
$split && return 0
if [[ "$cur" == -* ]]; then if [[ "$cur" == -* ]]; then
COMPREPLY=( $( compgen -W '--inputfile -i --outputfile -o \ COMPREPLY=( $( compgen -W '--inputfile -i --outputfile -o \
@ -362,14 +389,16 @@ complete -F _config_list $filenames config_list
have arch && have arch &&
_arch() _arch()
{ {
local cur prev local cur prev split=false
COMPREPLY=() COMPREPLY=()
cur=`_get_cword` cur=`_get_cword`
prev=${COMP_WORDS[COMP_CWORD-1]} prev=${COMP_WORDS[COMP_CWORD-1]}
_split_longopt && split=true
case "$prev" in case "$prev" in
-@(w|g|d|--welcome-msg=|-goodbye-msg|-digest=)) -@(w|g|d|--welcome-msg|-goodbye-msg|-digest))
COMPREPLY=( $( compgen -W 'y n' -- $cur) ) COMPREPLY=( $( compgen -W 'y n' -- $cur) )
return 0 return 0
;; ;;
@ -379,8 +408,10 @@ _arch()
;; ;;
esac esac
$split && return 0
if [[ "$cur" == -* ]]; then if [[ "$cur" == -* ]]; then
COMPREPLY=( $( compgen -W '--wipe -s --start= -e --end= \ COMPREPLY=( $( compgen -W '--wipe -s --start -e --end \
-q --quiet -h --help' -- $cur ) ) -q --quiet -h --help' -- $cur ) )
else else
args=$COMP_CWORD args=$COMP_CWORD
@ -421,21 +452,25 @@ complete -F _cleanarch cleanarch
have inject && have inject &&
_inject() _inject()
{ {
local cur prev local cur prev split=false
COMPREPLY=() COMPREPLY=()
cur=`_get_cword` cur=`_get_cword`
prev=${COMP_WORDS[COMP_CWORD-1]} prev=${COMP_WORDS[COMP_CWORD-1]}
_split_longopt && split=true
case "$prev" in case "$prev" in
-@(l|-listname=)) -@(l|-listname))
_mailman_lists _mailman_lists
return 0 return 0
;; ;;
esac esac
$split && return 0
if [[ "$cur" == -* ]]; then if [[ "$cur" == -* ]]; then
COMPREPLY=( $( compgen -W '-l --listname= -q --queue= \ COMPREPLY=( $( compgen -W '-l --listname -q --queue \
-h --help' -- $cur ) ) -h --help' -- $cur ) )
else else
_filedir _filedir
@ -527,13 +562,16 @@ complete -F _mmsitepass mmsitepass
have qrunner && have qrunner &&
_qrunner() _qrunner()
{ {
local cur local cur prev
COMPREPLY=() COMPREPLY=()
cur=`_get_cword` cur=`_get_cword`
prev=${COMP_WORDS[COMP_CWORD-1]}
_split_longopt && return 0
if [[ "$cur" == -* ]]; then if [[ "$cur" == -* ]]; then
COMPREPLY=( $( compgen -W '-r --runner= --once -o \ COMPREPLY=( $( compgen -W '-r --runner --once -o \
-l --list -v --verbose -s --subproc -h --help' -- $cur ) ) -l --list -v --verbose -s --subproc -h --help' -- $cur ) )
fi fi