pkg-get/scripts/pkg-get_completion.sh

80 lines
3.2 KiB
Bash
Raw Permalink Normal View History

2006-07-13 04:21:42 +02:00
# pkg-get(8) completion by Simone Rota
# derived form Johannes Winkelmann's prt-get completion
# problems: options ending on = should not add a space afterwards
_pkg-get()
{
local cur prev
2006-07-13 04:21:42 +02:00
COMPREPLY=()
cur=${COMP_WORDS[COMP_CWORD]}
prev=${COMP_WORDS[COMP_CWORD-1]}
2006-07-13 04:21:42 +02:00
if [ $COMP_CWORD -eq 1 ]; then
COMPREPLY=( $( compgen -W ' \
2006-07-13 04:21:42 +02:00
install depinst update help \
version readme list info path \
search dsearch printf sync \
dependent sysup current lock unlock \
listlocked diff quickdiff depends quickdep \
dup isinst remove listinst' $cur ))
fi
if [ $COMP_CWORD '>' 1 ]; then
if [[ "$cur" != -* ]]; then
case ${COMP_WORDS[1]} in
2006-07-13 04:21:42 +02:00
"install" | "depinst" | "path" | "dependent" | \
"depends" | "quickdep" | "info" | "readme" | "isinst" )
plist=`pkg-get list`
if [ -n "$plist" ]; then
COMPREPLY=( $( compgen -W '$plist' $cur ) )
fi
2006-07-13 04:21:42 +02:00
;;
"current"|"lock"|"remove")
plist=`pkg-get listinst`
COMPREPLY=( $( compgen -W '$plist' $cur ) )
;;
"update")
plist=`pkg-get quickdiff`
COMPREPLY=( $( compgen -W '$plist' $cur ) )
;;
"unlock")
plist=`pkg-get listlocked`
COMPREPLY=( $( compgen -W '$plist' $cur ) )
;;
esac
else
case ${COMP_WORDS[1]} in
"install" | "sysup")
COMPREPLY=( $( compgen -W '-do \
-im \
--pre-install \
--post-install \
--install-scripts' \
-- $cur ) )
;;
"update")
2006-07-13 04:21:42 +02:00
COMPREPLY=( $( compgen -W '-do \
-im \
-fr \
--pre-install \
2006-07-13 04:21:42 +02:00
--pre-install \
--post-install \
--install-scripts' \
-- $cur ) )
2006-07-13 04:21:42 +02:00
;;
"dependent" )
COMPREPLY=( $( compgen -W '--all' -- $cur ) )
;;
"printf" )
COMPREPLY=( $( compgen -W '--filter=' -- $cur ) )
;;
esac
fi
fi
return 0
2006-07-13 04:21:42 +02:00
}
complete -F _pkg-get -o default pkg-get