]> review.fuel-infra Code Review - openstack-build/heat-build.git/commitdiff
heat cli : Add bash_completion.d entry for heat
authorSteven Hardy <shardy@redhat.com>
Fri, 20 Apr 2012 19:54:04 +0000 (20:54 +0100)
committerSteven Hardy <shardy@redhat.com>
Fri, 20 Apr 2012 20:27:06 +0000 (21:27 +0100)
issue #87 Adds basic bash smart-complete script for heat to bash_completion.d

Signed-off-by: Steven Hardy <shardy@redhat.com>
etc/bash_completion.d/heat [new file with mode: 0644]
setup.py

diff --git a/etc/bash_completion.d/heat b/etc/bash_completion.d/heat
new file mode 100644 (file)
index 0000000..0cde406
--- /dev/null
@@ -0,0 +1,18 @@
+_heat()
+{
+    local cur prev opts
+    COMPREPLY=()
+    cur="${COMP_WORDS[COMP_CWORD]}"
+    prev="${COMP_WORDS[COMP_CWORD-1]}"
+    opts=`for i in $(heat --help | grep -A100 "^Commands" | grep -B100 "^Options" | grep "^\s*[a-z]" | awk '{print $1}'); do echo $i; done`
+
+        if [[ ${cur} == * ]]; then
+            if [[ ${#COMP_WORDS[@]} -gt 2 ]]; then
+                return 0
+            else
+                COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
+                return 0
+            fi
+        fi
+}
+complete -F _heat heat
index 8fc0690caffc529237384c26300bbd05242f5713..1837ae02a2b8e268ab36dc13f4be056a1b80854d 100755 (executable)
--- a/setup.py
+++ b/setup.py
@@ -95,6 +95,7 @@ setup(
                                'etc/heat-api-paste.ini',
                                'etc/heat-engine.conf',
                                'etc/heat-engine-paste.ini']),
+                ('/etc/bash_completion.d', ['etc/bash_completion.d/heat']),
                 ('/var/log/heat', ['var/log/heat/api.log',
                                    'var/log/heat/engine.log']),
                 ('/var/lib/heat', ['var/lib/heat/.dummy'])],