2012-01-12 19:54:06 +04:00
|
|
|
# slapt-get(8) completion -*- shell-script -*-
|
2010-07-05 02:08:42 +04:00
|
|
|
|
2011-03-28 20:20:02 +04:00
|
|
|
_slapt_get()
|
2010-07-05 02:08:42 +04:00
|
|
|
{
|
2011-04-22 03:03:22 +04:00
|
|
|
local cur prev words cword
|
|
|
|
_init_completion || return
|
2010-07-05 02:08:42 +04:00
|
|
|
|
2011-06-08 04:02:34 +04:00
|
|
|
case "$prev" in
|
|
|
|
--config|-c)
|
|
|
|
_filedir
|
2011-11-20 17:00:03 +03:00
|
|
|
return
|
2011-06-08 04:02:34 +04:00
|
|
|
;;
|
|
|
|
--retry|--search)
|
|
|
|
# argument required but no completions available
|
2011-11-20 17:00:03 +03:00
|
|
|
return
|
2011-06-08 04:02:34 +04:00
|
|
|
;;
|
|
|
|
esac
|
|
|
|
|
2010-07-05 02:08:42 +04:00
|
|
|
if [[ "$cur" == -* ]]; then
|
2011-11-20 23:42:20 +03:00
|
|
|
COMPREPLY=( $( compgen -W '$( _parse_help "$1" --help )' -- "$cur" ) )
|
2011-06-12 18:27:22 +04:00
|
|
|
[[ $COMPREPLY == *= ]] && compopt -o nospace
|
2011-11-20 17:00:03 +03:00
|
|
|
[[ $COMPREPLY ]] && return
|
2010-07-05 02:08:42 +04:00
|
|
|
fi
|
|
|
|
|
2011-06-11 14:57:01 +04:00
|
|
|
local i t
|
2010-07-05 04:23:23 +04:00
|
|
|
# search for last action (--install|--install-set|--remove|--show|--filelist)
|
|
|
|
for (( i=${#words[@]}-1; i>0; i-- )); do
|
2011-06-12 18:03:08 +04:00
|
|
|
if [[ ${words[i]} == --show ]]; then
|
2010-07-05 04:23:23 +04:00
|
|
|
t="all"
|
|
|
|
break
|
2011-06-12 18:03:08 +04:00
|
|
|
elif [[ ${words[i]} == -@(i|-install) ]]; then
|
|
|
|
t="avl"
|
|
|
|
break
|
2010-07-05 04:23:23 +04:00
|
|
|
elif [[ ${words[i]} == --install-set ]]; then
|
|
|
|
t="set"
|
|
|
|
break
|
2010-07-09 21:46:43 +04:00
|
|
|
elif [[ ${words[i]} == --@(remove|filelist) ]]; then
|
2010-07-05 04:23:23 +04:00
|
|
|
t="ins"
|
|
|
|
break
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
|
2011-06-12 18:03:08 +04:00
|
|
|
local config="/etc/slapt-get/slapt-getrc" # default config location
|
|
|
|
# search for config
|
|
|
|
for (( i=${#words[@]}-1; i>0; i-- )); do
|
|
|
|
if [[ ${words[i]} == -@(c|-config) ]]; then
|
|
|
|
config="${words[i+1]}"
|
|
|
|
break
|
|
|
|
fi
|
|
|
|
done
|
2012-01-12 19:54:06 +04:00
|
|
|
[[ -r "$config" ]] || return
|
2011-06-12 18:03:08 +04:00
|
|
|
|
2010-07-05 04:23:23 +04:00
|
|
|
case $t in
|
2011-06-12 18:03:08 +04:00
|
|
|
all) # --show
|
2011-01-25 03:48:34 +03:00
|
|
|
# slapt-get will fail to search for "^name-version"
|
|
|
|
# it can search for names only
|
2011-06-12 18:03:08 +04:00
|
|
|
local name=${cur%%-*}
|
2011-11-20 23:42:20 +03:00
|
|
|
COMPREPLY=( $( slapt-get -c $config --search "^$name" 2>/dev/null |\
|
|
|
|
sed -ne "/^$cur/{s/ .*$//;p}" ) )
|
2011-11-20 17:00:03 +03:00
|
|
|
return
|
2010-07-05 02:08:42 +04:00
|
|
|
;;
|
2011-06-12 18:03:08 +04:00
|
|
|
avl) # --install|-i|
|
2011-11-20 23:42:20 +03:00
|
|
|
COMPREPLY=( $( slapt-get -c $config --available 2>/dev/null | \
|
|
|
|
sed -ne "/^$cur/{s/ .*$//;p}" ) )
|
2011-11-20 17:00:03 +03:00
|
|
|
return
|
2011-06-12 18:03:08 +04:00
|
|
|
;;
|
2010-07-09 21:46:43 +04:00
|
|
|
ins) # --remove|--filelist
|
2011-11-20 23:42:20 +03:00
|
|
|
COMPREPLY=( $( cd /var/log/packages; compgen -f -- "$cur" ) )
|
2011-11-20 17:00:03 +03:00
|
|
|
return
|
2010-07-05 02:08:42 +04:00
|
|
|
;;
|
2010-07-05 19:15:53 +04:00
|
|
|
set) # --install-set
|
2011-11-20 23:42:20 +03:00
|
|
|
COMPREPLY=( $( compgen -W 'a ap d e f k kde kdei l n t tcl x
|
2012-07-25 02:39:23 +04:00
|
|
|
xap xfce y' -- "$cur" ) )
|
2011-11-20 17:00:03 +03:00
|
|
|
return
|
2010-07-05 02:08:42 +04:00
|
|
|
;;
|
|
|
|
esac
|
2011-03-28 20:20:02 +04:00
|
|
|
} && complete -F _slapt_get slapt-get
|
2010-07-25 19:53:11 +04:00
|
|
|
|
2011-05-02 13:18:33 +03:00
|
|
|
# ex: ts=4 sw=4 et filetype=sh
|