summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndreas Kreuzer <andreas.kreuzer@open-infrastructure.net>2016-06-17 11:45:51 +0000
committerDaniel Baumann <daniel.baumann@open-infrastructure.net>2016-07-01 09:22:29 +0000
commit5b4e4616d4f27eb54ca0d249f88b6ec236a602f2 (patch)
tree69be76f2616e44209b857d86053eeccb34686328
parentUpdating Git URL in installation instructions. (diff)
downloadcompute-tools-5b4e4616d4f27eb54ca0d249f88b6ec236a602f2.tar.xz
compute-tools-5b4e4616d4f27eb54ca0d249f88b6ec236a602f2.zip
Fixing bash-completion.
Signed-off-by: Andreas Kreuzer <andreas.kreuzer@open-infrastructure.net> Signed-off-by: Daniel Baumann <daniel.baumann@open-infrastructure.net>
-rw-r--r--Makefile2
-rw-r--r--share/bash-completion/container215
-rw-r--r--share/bash-completion/container-tools215
3 files changed, 217 insertions, 215 deletions
diff --git a/Makefile b/Makefile
index d22c32c..1a411c2 100644
--- a/Makefile
+++ b/Makefile
@@ -84,6 +84,7 @@ install: build
ln -sf container.1 $(DESTDIR)/usr/share/man/man1/cnt.1
ln -sf container-shell $(DESTDIR)/usr/bin/cntsh
ln -sf container-shell.1 $(DESTDIR)/usr/share/man/man1/cntsh.1
+ ln -sf container ${DESTDIR}/usr/share/bash-completion/completions/cnt
ln -sf debconf ${DESTDIR}/usr/share/$(SOFTWARE)/scripts/debian
ln -sf debconf.d ${DESTDIR}/usr/share/$(SOFTWARE)/scripts/debian.d
@@ -120,6 +121,7 @@ uninstall:
rm -f $(DESTDIR)/usr/share/man/man1/cnt.1
rm -f $(DESTDIR)/usr/bin/cntsh
rm -f $(DESTDIR)/usr/share/man/man1/cntsh.1
+ rm -f ${DESTDIR}/usr/share/bash-completion/completions/cnt
for FILE in share/bash-completion/*; \
do \
diff --git a/share/bash-completion/container b/share/bash-completion/container
new file mode 100644
index 0000000..1e5bf51
--- /dev/null
+++ b/share/bash-completion/container
@@ -0,0 +1,215 @@
+# Open Infrastructure: container-tools
+# Copyright (C) 2016 Andreas Kreuzer <andreas.kreuzer@open-infrastructure.net>
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+_container()
+{
+ local cur prev cmd opts
+ COMPREPLY=()
+ cur="${COMP_WORDS[COMP_CWORD]}"
+ prev="${COMP_WORDS[COMP_CWORD-1]}"
+
+ if [ ${COMP_CWORD} -gt 0 ]
+ then
+ cmd="${COMP_WORDS[1]}"
+ fi
+
+ if [ "${prev}" = "--" ]
+ then
+ compopt -o bashdefault
+ COMPREPLY=( $(compgen -c -- $cur) )
+ return 0
+ fi
+
+ case "${cmd}" in
+ console)
+ case "${cur}" in
+ -*)
+ opts="-n --name"
+ COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
+ return 0
+ ;;
+
+ *)
+ case "${prev}" in
+ -n|--name)
+ opts=$(container list -s -f short)
+ COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
+ return 0
+ ;;
+ esac
+ ;;
+ esac
+ ;;
+
+ create)
+ case "${cur}" in
+ -*)
+ opts="-n --name -c --capability -d --drop-capability -s --script -b --bind"
+ COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
+ return 0
+ ;;
+
+ *)
+ case "${prev}" in
+ -n|--name)
+ opts=$(cd /srv/container/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="debootstrap debconf default"
+ COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
+ return 0
+ ;;
+ esac
+ ;;
+ 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"
+ COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
+ return 0
+ ;;
+
+ *)
+ case "${prev}" in
+ -n|--name)
+ opts=$(container list -a -f short)
+ COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
+ return 0
+ ;;
+ esac
+ ;;
+ esac
+ ;;
+
+ list)
+ case "${cur}" in
+ -*)
+ opts="-a --all -f --format -h --host -s --started -t --stopped"
+ COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
+ return 0
+ ;;
+
+ *)
+ case "${prev}" in
+ -h|--host)
+ opts="true false $(hostname -f)"
+ COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
+ return 0
+ ;;
+ esac
+ ;;
+ esac
+ ;;
+
+ remove)
+ case "${cur}" in
+ -*)
+ opts="-n --name -f --force"
+ COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
+ return 0
+ ;;
+
+ *)
+ case "${prev}" in
+ -n|--name)
+ opts=$(container list -a -f short)
+ COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
+ return 0
+ ;;
+ esac
+ ;;
+ esac
+ ;;
+
+ restart)
+ case "${cur}" in
+ -*)
+ opts="-n --name"
+ COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
+ return 0
+ ;;
+
+ *)
+ case "${prev}" in
+ -n|--name)
+ opts=$(container list -s -f short)
+ COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
+ return 0
+ ;;
+ esac
+ ;;
+ esac
+ ;;
+
+ start)
+ case "${cur}" in
+ -*)
+ opts="-n --name"
+ COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
+ return 0
+ ;;
+
+ *)
+ case "${prev}" in
+ -n|--name)
+ opts=$(container list -t -f short)
+ COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
+ return 0
+ ;;
+ esac
+ ;;
+ esac
+ ;;
+
+ stop)
+ case "${cur}" in
+ -*)
+ opts="-n --name -f --force"
+ COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
+ return 0
+ ;;
+
+ *)
+ case "${prev}" in
+ -n|--name)
+ opts=$(container list -s -f short)
+ COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
+ return 0
+ ;;
+ esac
+ ;;
+ esac
+ ;;
+
+ *)
+ local commands=$(ls /usr/lib/container-tools/container/)
+ COMPREPLY=( $(compgen -W "${commands}" -- ${cur}) )
+ return 0
+ ;;
+ esac
+
+ compopt -o filenames
+ COMPREPLY=( $(compgen -f -- $cur) )
+ return 0
+}
+
+complete -F _container container cnt
diff --git a/share/bash-completion/container-tools b/share/bash-completion/container-tools
deleted file mode 100644
index 219fd2f..0000000
--- a/share/bash-completion/container-tools
+++ /dev/null
@@ -1,215 +0,0 @@
-# Open Infrastructure: container-tools
-# Copyright (C) 2016 Andreas Kreuzer <andreas.kreuzer@open-infrastructure.net>
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program. If not, see <http://www.gnu.org/licenses/>.
-
-_container()
-{
- local cur prev cmd opts
- COMPREPLY=()
- cur="${COMP_WORDS[COMP_CWORD]}"
- prev="${COMP_WORDS[COMP_CWORD-1]}"
-
- if [ ${COMP_CWORD} -gt 0 ]
- then
- cmd="${COMP_WORDS[1]}"
- fi
-
- if [ "${prev}" = "--" ]
- then
- compopt -o bashdefault
- COMPREPLY=( $(compgen -c -- $cur) )
- return 0
- fi
-
- case "${cmd}" in
- console)
- case "${cur}" in
- -*)
- opts="-n --name"
- COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
- return 0
- ;;
-
- *)
- case "${prev}" in
- -n|--name)
- opts=$(container list -s -f short)
- COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
- return 0
- ;;
- esac
- ;;
- esac
- ;;
-
- create)
- case "${cur}" in
- -*)
- opts="-n --name -c --capability -d --drop-capability -s --script -b --bind"
- COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
- return 0
- ;;
-
- *)
- case "${prev}" in
- -n|--name)
- opts=$(cd /srv/container/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="debootstrap debconf default"
- COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
- return 0
- ;;
- esac
- ;;
- 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"
- COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
- return 0
- ;;
-
- *)
- case "${prev}" in
- -n|--name)
- opts=$(container list -a -f short)
- COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
- return 0
- ;;
- esac
- ;;
- esac
- ;;
-
- list)
- case "${cur}" in
- -*)
- opts="-a --all -f --format -h --host -s --started -t --stopped"
- COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
- return 0
- ;;
-
- *)
- case "${prev}" in
- -h|--host)
- opts="true false $(hostname -f)"
- COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
- return 0
- ;;
- esac
- ;;
- esac
- ;;
-
- remove)
- case "${cur}" in
- -*)
- opts="-n --name -f --force"
- COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
- return 0
- ;;
-
- *)
- case "${prev}" in
- -n|--name)
- opts=$(container list -a -f short)
- COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
- return 0
- ;;
- esac
- ;;
- esac
- ;;
-
- restart)
- case "${cur}" in
- -*)
- opts="-n --name"
- COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
- return 0
- ;;
-
- *)
- case "${prev}" in
- -n|--name)
- opts=$(container list -s -f short)
- COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
- return 0
- ;;
- esac
- ;;
- esac
- ;;
-
- start)
- case "${cur}" in
- -*)
- opts="-n --name"
- COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
- return 0
- ;;
-
- *)
- case "${prev}" in
- -n|--name)
- opts=$(container list -t -f short)
- COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
- return 0
- ;;
- esac
- ;;
- esac
- ;;
-
- stop)
- case "${cur}" in
- -*)
- opts="-n --name -f --force"
- COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
- return 0
- ;;
-
- *)
- case "${prev}" in
- -n|--name)
- opts=$(container list -s -f short)
- COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
- return 0
- ;;
- esac
- ;;
- esac
- ;;
-
- *)
- local commands=$(ls /usr/lib/container-tools/container/)
- COMPREPLY=( $(compgen -W "${commands}" -- ${cur}) )
- return 0
- ;;
- esac
-
- compopt -o filenames
- COMPREPLY=( $(compgen -f -- $cur) )
- return 0
-}
-
-complete -F _container container cnt