summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorZhiQiang Fan <aji.zqfan@gmail.com>2013-12-14 16:33:29 +0800
committerZhiQiang Fan <aji.zqfan@gmail.com>2013-12-16 23:04:24 +0800
commit992d6f5350952fc6501184b02c477134048952d6 (patch)
tree6270f4f48067aef01a06371d575d9ffa5d02f490 /tools
parent619995a3b508ada07f9f454918598c3d9d3d4381 (diff)
downloadpython-heatclient-992d6f5350952fc6501184b02c477134048952d6.tar.gz
Supports bash_completion for heatclient
bash_completion feature can improve CLI user experience, projects like nova, keystone, and cinder already support it. NOTE: this patch just provides simple functionality, which means cache for IDs and names is not used (like nova). Closes-Bug: #1260939 Change-Id: I327e884e1c5907c9ff6f31131c70aee659cca58e
Diffstat (limited to 'tools')
-rw-r--r--tools/heat.bash_completion27
1 files changed, 27 insertions, 0 deletions
diff --git a/tools/heat.bash_completion b/tools/heat.bash_completion
new file mode 100644
index 0000000..6d6da2b
--- /dev/null
+++ b/tools/heat.bash_completion
@@ -0,0 +1,27 @@
+# bash completion for openstack heat
+
+_heat_opts="" # lazy init
+_heat_flags="" # lazy init
+_heat_opts_exp="" # lazy init
+_heat()
+{
+ local cur prev kbc
+ COMPREPLY=()
+ cur="${COMP_WORDS[COMP_CWORD]}"
+ prev="${COMP_WORDS[COMP_CWORD-1]}"
+
+ if [ "x$_heat_opts" == "x" ] ; then
+ kbc="`heat bash-completion | sed -e "s/ -h / /"`"
+ _heat_opts="`echo "$kbc" | sed -e "s/--[a-z0-9_-]*//g" -e "s/[ ][ ]*/ /g"`"
+ _heat_flags="`echo " $kbc" | sed -e "s/ [^-][^-][a-z0-9_-]*//g" -e "s/[ ][ ]*/ /g"`"
+ _heat_opts_exp="`echo $_heat_opts | sed -e "s/[ ]/|/g"`"
+ fi
+
+ if [[ " ${COMP_WORDS[@]} " =~ " "($_heat_opts_exp)" " && "$prev" != "help" ]] ; then
+ COMPREPLY=($(compgen -W "${_heat_flags}" -- ${cur}))
+ else
+ COMPREPLY=($(compgen -W "${_heat_opts}" -- ${cur}))
+ fi
+ return 0
+}
+complete -F _heat heat