aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Mike Kelly <pioto@pioto.org> 2010-02-25 13:40:47 -0500
committerAvatar Mike Kelly <pioto@pioto.org> 2010-02-25 13:40:47 -0500
commit15ba5fd75f7e71fa32a96864f1ee93720241ac5e (patch)
tree5a6440318bd4a7d9eca8173c1956e17dd59d856a
parent8c20a6552fa820021d9952835a5f9724e5870263 (diff)
downloadpaludis-15ba5fd75f7e71fa32a96864f1ee93720241ac5e.tar.gz
paludis-15ba5fd75f7e71fa32a96864f1ee93720241ac5e.tar.xz
rework cave completion a bit. completion for cave-help and cave-sync
-rw-r--r--bash-completion/cave55
1 files changed, 41 insertions, 14 deletions
diff --git a/bash-completion/cave b/bash-completion/cave
index 305a7a5..80dc2b7 100644
--- a/bash-completion/cave
+++ b/bash-completion/cave
@@ -4,7 +4,7 @@
# Based in part upon 'git' bash completion from git-1.6.4.2
-_cave_find_cmd() {
+__cave_find_cmd() {
local w c=1 cmd
while [[ $c -lt $COMP_CWORD ]] ; do
@@ -19,22 +19,49 @@ _cave_find_cmd() {
echo "${cmd}"
}
-_cave() {
- local cmd="$(_cave_find_cmd)" cur="${COMP_WORDS[COMP_CWORD]}"
+__cave_global() {
+ case "${prev}" in
+ --log-level)
+ COMPREPLY=( $(compgen -W "debug qa warning slient" -- "${cur}") )
+ ;;
+ --environment|-E)
+ COMPREPLY=( $(compgen -W "paludis: portage:" -- "${cur}") )
+ ;;
+ *)
+ case "${cur}" in
+ -*)
+ COMPREPLY=( $(compgen -W "-E --environment --log-level" -- "${cur}") )
+ ;;
+ *)
+ COMPREPLY=( $(compgen -W "$(cave print-commands -a)" -- "${cur}") )
+ ;;
+ esac
+ esac
+}
- if [[ -z "${cmd}" ]] ; then
- case "${cur}" in
- --*)
- COMPREPLY=( $(compgen -W "--environment --log-level" -- "${cur}") )
- ;;
- *)
- COMPREPLY=( $(compgen -W "$(cave print-commands)" -- "${cur}") )
- ;;
- esac
- return
+__cave_help() {
+ # only complete once
+ if [[ "${prev}" == "help" ]] ; then
+ COMPREPLY=( $(compgen -W "$(cave print-commands -a) -a --all" -- "${cur}") )
fi
+}
+
+__cave_sync() {
+ COMPREPLY=( $(compgen -W "$(cave print-repositories) --sequential" -- "${cur}") )
+}
+
+_cave() {
+ local cmd=`_cave_find_cmd` prev=`_get_pword` cur=`_get_cword`
COMPREPLY=()
+
+ if [[ -z "${cmd}" ]] ; then
+ __cave_global
+ else
+ if [[ "$(type -t "__cave_${cmd}")" == "function" ]] ; then
+ "__cave_${cmd}"
+ fi
+ fi
}
-complete -o bashdefault -o default -F _cave cave
+complete -F _cave cave