summaryrefslogtreecommitdiffstats
path: root/share
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@open-infrastructure.net>2017-01-03 22:43:27 +0000
committerDaniel Baumann <daniel.baumann@open-infrastructure.net>2017-01-04 10:27:37 +0000
commit641937cec6d5c11788dbd01f4fbec54de4886e32 (patch)
treec62062e51abff9eeee12b212ed31dc6546f89ff5 /share
parentUsing generic directory instead of local directory for debconf files to bash-... (diff)
downloadcompute-tools-641937cec6d5c11788dbd01f4fbec54de4886e32.tar.xz
compute-tools-641937cec6d5c11788dbd01f4fbec54de4886e32.zip
Reordering bash-completion to do completion the usual way (by suggesting commands first, then options and finally their arguments, rather than commands and arguments only).
Signed-off-by: Daniel Baumann <daniel.baumann@open-infrastructure.net>
Diffstat (limited to 'share')
-rw-r--r--share/bash-completion/container210
1 files changed, 81 insertions, 129 deletions
diff --git a/share/bash-completion/container b/share/bash-completion/container
index 546a896..0bc22c0 100644
--- a/share/bash-completion/container
+++ b/share/bash-completion/container
@@ -37,243 +37,195 @@ _container()
case "${cmd}" in
auto)
- case "${cur}" in
- -*)
- opts="-f --force -s --start -t --stop"
- COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
- return 0
- ;;
- esac
+ opts="-f --force -s --start -t --stop"
+ COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
+ return 0
;;
console)
- case "${cur}" in
- -*)
- opts="-n --name"
+ case "${prev}" in
+ -n|--name)
+ opts=$(container list -s -f shell)
COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
return 0
;;
*)
- case "${prev}" in
- -n|--name)
- opts=$(container list -s -f shell)
- COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
- return 0
- ;;
- esac
+ opts="-n --name"
+ COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
+ return 0
;;
esac
;;
create)
- case "${cur}" in
- -*)
- opts="-n --name -c --capability -d --drop-capability -s --script -b --bind"
+ case "${prev}" in
+ -n|--name)
+ opts=$(cd /etc/container-tools/debconf 2>/dev/null && ls *.cfg 2>/dev/null | sed -e 's/.cfg$//g')
+ COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
+ return 0
+ ;;
+
+ -s|--script)
+ opts=$(cd /usr/share/container-tools/scripts && find -maxdepth 1 -not -type d -and -not -name 'default' -and -not -name 'debconf' -and -not -name '*.d' -printf '%P\n' | sort)
COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
return 0
;;
*)
- case "${prev}" in
- -n|--name)
- opts=$(cd /etc/container-tools/debconf 2>/dev/null && ls *.cfg 2>/dev/null | sed -e 's/.cfg$//g')
- COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
- return 0
- ;;
-
- -s|--script)
- opts=$(cd /usr/share/container-tools/scripts && find -maxdepth 1 -not -type d -and -not -name 'default' -and -not -name 'debconf' -and -not -name '*.d' -printf '%P\n' | sort)
- COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
- return 0
- ;;
- esac
+ opts="-n --name -c --capability -d --drop-capability -s --script -b --bind"
+ COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
+ return 0
;;
esac
;;
enter)
- case "${cur}" in
- -*)
- opts="-n --name"
+ case "${prev}" in
+ -n|--name)
+ opts=$(container list -s -f shell)
COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
return 0
;;
*)
- case "${prev}" in
- -n|--name)
- opts=$(container list -s -f shell)
- COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
- return 0
- ;;
- esac
+ opts="-n --name"
+ COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
+ return 0
;;
esac
;;
limit)
- case "${cur}" in
- -*)
- opts="-n --name --blockio-device-weight --blockio-read-bandwith -b --blockio-weight --blockio-write-bandwith -c --cpu-quota --cpu-shares -m --memory-limit -t --tasks-max"
+ case "${prev}" in
+ -n|--name)
+ opts=$(container list -a -f shell)
COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
return 0
;;
*)
- case "${prev}" in
- -n|--name)
- opts=$(container list -a -f shell)
- COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
- return 0
- ;;
- esac
+ opts="-n --name --blockio-device-weight --blockio-read-bandwith -b --blockio-weight --blockio-write-bandwith -c --cpu-quota --cpu-shares -m --memory-limit -t --tasks-max"
+ COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
+ return 0
;;
esac
;;
list|ls)
- case "${cur}" in
- -*)
- opts="-a --all -f --format -h --host -o --other -s --started -t --stopped"
+ case "${prev}" in
+ -h|--host)
+ opts="true false $(hostname -f)"
+ COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
+ return 0
+ ;;
+
+ -f|--format)
+ opts="cli csv json nwdiag shell yaml xml"
COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
return 0
;;
*)
- case "${prev}" in
- -h|--host)
- opts="true false $(hostname -f)"
- COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
- return 0
- ;;
-
- -f|--format)
- opts="cli csv json nwdiag shell yaml xml"
- COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
- return 0
- ;;
- esac
+ opts="-a --all -f --format -h --host -o --other -s --started -t --stopped"
+ COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
+ return 0
;;
esac
;;
move|mv)
- case "${cur}" in
- -*)
- opts="-f --force -n --new -o --old"
+ case "${prev}" in
+ -o|--old)
+ opts=$(container list -t -f shell)
COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
return 0
;;
*)
- case "${prev}" in
- -o|--old)
- opts=$(container list -t -f shell)
- COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
- return 0
- ;;
- esac
+ opts="-f --force -n --new -o --old"
+ COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
+ return 0
;;
esac
;;
remove|rm)
- case "${cur}" in
- -*)
- opts="-n --name -f --force"
+ case "${prev}" in
+ -n|--name)
+ opts=$(container list -t -f shell)
COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
return 0
;;
*)
- case "${prev}" in
- -n|--name)
- opts=$(container list -t -f shell)
- COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
- return 0
- ;;
- esac
+ opts="-n --name -f --force"
+ COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
+ return 0
;;
esac
;;
restart)
- case "${cur}" in
- -*)
- opts="-n --name"
+ case "${prev}" in
+ -n|--name)
+ opts=$(container list -s -f shell)
COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
return 0
;;
*)
- case "${prev}" in
- -n|--name)
- opts=$(container list -s -f shell)
- COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
- return 0
- ;;
- esac
+ opts="-n --name"
+ COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
+ return 0
;;
esac
;;
start)
- case "${cur}" in
- -*)
- opts="-n --name"
+ case "${prev}" in
+ -n|--name)
+ opts=$(container list -t -f shell)
COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
return 0
;;
*)
- case "${prev}" in
- -n|--name)
- opts=$(container list -t -f shell)
- COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
- return 0
- ;;
- esac
+ opts="-n --name"
+ COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
+ return 0
;;
esac
;;
status)
- case "${cur}" in
- -*)
- opts="-n --name"
+ case "${prev}" in
+ -n|--name)
+ opts=$(container list -t -f shell)
COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
return 0
;;
*)
- case "${prev}" in
- -n|--name)
- opts=$(container list -t -f shell)
- COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
- return 0
- ;;
- esac
+ opts="-n --name"
+ COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
+ return 0
;;
esac
;;
stop)
- case "${cur}" in
- -*)
- opts="-n --name -f --force"
+ case "${prev}" in
+ -n|--name)
+ opts=$(container list -s -f shell)
COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
return 0
;;
*)
- case "${prev}" in
- -n|--name)
- opts=$(container list -s -f shell)
- COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
- return 0
- ;;
- esac
+ opts="-n --name -f --force"
+ COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
+ return 0
;;
esac
;;