kcov, pkgtools, sbopkg, slapt: Move option completion code after option argument completions

otherwise bogus completions are produced for option argument completions
starting with a dash
This commit is contained in:
Igor Murzov 2011-06-08 04:02:34 +04:00
parent 166b4bbb50
commit ac79f44d90
4 changed files with 51 additions and 47 deletions

View File

@ -5,12 +5,6 @@ _kcov()
local cur prev words cword split local cur prev words cword split
_init_completion -s || return _init_completion -s || return
if [[ "$cur" == -* ]]; then
COMPREPLY=( $( compgen -W '$( _parse_help "$1" --help )' -- "$cur" ) )
[[ $COMPREPLY == *= ]] && compopt -o nospace
return 0
fi
case "$prev" in case "$prev" in
--pid|-p) --pid|-p)
_pids _pids
@ -32,6 +26,12 @@ _kcov()
$split && return 0 $split && return 0
if [[ "$cur" == -* ]]; then
COMPREPLY=( $( compgen -W '$( _parse_help "$1" --help )' -- "$cur" ) )
[[ $COMPREPLY == *= ]] && compopt -o nospace
return 0
fi
_filedir _filedir
} && complete -F _kcov kcov } && complete -F _kcov kcov

View File

@ -8,12 +8,6 @@ _pkgtool()
{ {
local cur prev words cword local cur prev words cword
_init_completion || return _init_completion || return
if [[ "$cur" == -* ]]; then
COMPREPLY=( $( compgen -W '--sets --ignore-tagfiles --tagfile \
--source-mounted --source_dir --target_dir --source_device' \
-- "$cur" ) )
return 0
fi
case "$prev" in case "$prev" in
--source_dir|--target_dir) --source_dir|--target_dir)
@ -33,6 +27,13 @@ _pkgtool()
return 0 return 0
;; ;;
esac esac
if [[ "$cur" == -* ]]; then
COMPREPLY=( $( compgen -W '--sets --ignore-tagfiles --tagfile \
--source-mounted --source_dir --target_dir --source_device' \
-- "$cur" ) )
return 0
fi
} && } &&
complete -F _pkgtool pkgtool complete -F _pkgtool pkgtool
@ -58,6 +59,7 @@ _upgradepkg()
{ {
local cur prev words cword local cur prev words cword
_init_completion || return _init_completion || return
if [[ "$cur" == -* ]]; then if [[ "$cur" == -* ]]; then
COMPREPLY=( $( compgen -W '--dry-run --install-new --reinstall \ COMPREPLY=( $( compgen -W '--dry-run --install-new --reinstall \
--verbose' -- "$cur") ) --verbose' -- "$cur") )
@ -72,11 +74,6 @@ _installpkg()
{ {
local cur prev words cword local cur prev words cword
_init_completion || return _init_completion || return
if [[ "$cur" == -* ]]; then
COMPREPLY=( $( compgen -W '--warn --md5sum --root --infobox --terse \
--menu --ask --priority --tagfile' -- "$cur") )
return 0
fi
case "$prev" in case "$prev" in
--root) --root)
@ -93,6 +90,12 @@ _installpkg()
;; ;;
esac esac
if [[ "$cur" == -* ]]; then
COMPREPLY=( $( compgen -W '--warn --md5sum --root --infobox --terse \
--menu --ask --priority --tagfile' -- "$cur") )
return 0
fi
_filedir "t[bglx]z" _filedir "t[bglx]z"
} && complete -F _installpkg installpkg } && complete -F _installpkg installpkg
@ -101,11 +104,6 @@ _makepkg()
{ {
local cur prev words cword local cur prev words cword
_init_completion || return _init_completion || return
if [[ "$cur" == -* ]]; then
COMPREPLY=( $( compgen -W '-l --linkadd -p --prepend \
-c --chown' -- "$cur") )
return 0
fi
case "$prev" in case "$prev" in
-l|--linkadd|-c|--chown) -l|--linkadd|-c|--chown)
@ -114,6 +112,12 @@ _makepkg()
;; ;;
esac esac
if [[ "$cur" == -* ]]; then
COMPREPLY=( $( compgen -W '-l --linkadd -p --prepend \
-c --chown' -- "$cur") )
return 0
fi
_filedir _filedir
} && complete -F _makepkg makepkg } && complete -F _makepkg makepkg

View File

@ -7,12 +7,6 @@ _sbopkg()
local cur prev words cword local cur prev words cword
_init_completion || return _init_completion || return
if [[ "$cur" == -* ]]; then
COMPREPLY=( $( compgen -W '-b -c -d -e -f -g -h -i -k -l \
-o -P -p -q -R -r -s -u -V -v' -- "$cur" ) )
return 0
fi
case "$prev" in case "$prev" in
-e) -e)
COMPREPLY=( $( compgen -W 'ask continue stop' -- "$cur" ) ) COMPREPLY=( $( compgen -W 'ask continue stop' -- "$cur" ) )
@ -38,6 +32,12 @@ _sbopkg()
;; ;;
esac esac
if [[ "$cur" == -* ]]; then
COMPREPLY=( $( compgen -W '-b -c -d -e -f -g -h -i -k -l \
-o -P -p -q -R -r -s -u -V -v' -- "$cur" ) )
return 0
fi
local config="/etc/sbopkg/sbopkg.conf" local config="/etc/sbopkg/sbopkg.conf"
for (( i=${#words[@]}-1; i>0; i-- )); do for (( i=${#words[@]}-1; i>0; i-- )); do

View File

@ -6,6 +6,17 @@ _slapt_get()
local cur prev words cword local cur prev words cword
_init_completion || return _init_completion || return
case "$prev" in
--config|-c)
_filedir
return 0
;;
--retry|--search)
# argument required but no completions available
return 0
;;
esac
if [[ "$cur" == -* ]]; then if [[ "$cur" == -* ]]; then
COMPREPLY=( $( compgen -W '--download-only -d --simulate -s \ COMPREPLY=( $( compgen -W '--download-only -d --simulate -s \
--no-prompt -y --prompt -p --reinstall --ignore-excludes \ --no-prompt -y --prompt -p --reinstall --ignore-excludes \
@ -18,17 +29,6 @@ _slapt_get()
return 0 return 0
fi fi
case "$prev" in
--config|-c)
_filedir
return 0
;;
--retry|--search)
# argument required but no completions available
return 0
;;
esac
local t local t
# search for last action (--install|--install-set|--remove|--show|--filelist) # search for last action (--install|--install-set|--remove|--show|--filelist)
for (( i=${#words[@]}-1; i>0; i-- )); do for (( i=${#words[@]}-1; i>0; i-- )); do
@ -71,14 +71,6 @@ _slapt_src()
local cur prev words cword local cur prev words cword
_init_completion || return _init_completion || return
if [[ "$cur" == -* ]]; then
COMPREPLY=( $( compgen -W '--update -u --list -l --clean -e \
--search -s --show -w --install -i --build -b --fetch -f \
--yes -y --config -c --no-dep -n --postprocess -p \
--version -v --help -h' -- "$cur" ) )
return 0
fi
case "$prev" in case "$prev" in
--config|-c) --config|-c)
_filedir _filedir
@ -90,6 +82,14 @@ _slapt_src()
;; ;;
esac esac
if [[ "$cur" == -* ]]; then
COMPREPLY=( $( compgen -W '--update -u --list -l --clean -e \
--search -s --show -w --install -i --build -b --fetch -f \
--yes -y --config -c --no-dep -n --postprocess -p \
--version -v --help -h' -- "$cur" ) )
return 0
fi
local t local t
# search for last action (-i|-w|-b|-f) # search for last action (-i|-w|-b|-f)
for (( i=${#words[@]}-1; i>0; i-- )); do for (( i=${#words[@]}-1; i>0; i-- )); do