diff options
| author | Jenkins <jenkins@review.openstack.org> | 2014-07-15 18:58:11 +0000 |
|---|---|---|
| committer | Gerrit Code Review <review@openstack.org> | 2014-07-15 18:58:11 +0000 |
| commit | 25befcb5f9e02f7edca6ca156c980aca68bb3840 (patch) | |
| tree | 40fa198c19d7f89b9130bdc2c86dfd764f86412c /tools | |
| parent | c3665d091646cebce39a9656da0566f2c4477d8b (diff) | |
| parent | 1155530941ddeb1b948939fa400ba722ed5ccd0f (diff) | |
| download | python-ironicclient-25befcb5f9e02f7edca6ca156c980aca68bb3840.tar.gz | |
Merge "Add bash completion support for ironic cli"
Diffstat (limited to 'tools')
| -rw-r--r-- | tools/ironic.bash_completion | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/tools/ironic.bash_completion b/tools/ironic.bash_completion new file mode 100644 index 0000000..fbc32f2 --- /dev/null +++ b/tools/ironic.bash_completion @@ -0,0 +1,27 @@ +_ironic_opts="" # lazy init +_ironic_flags="" # lazy init +_ironic_opts_exp="" # lazy init +_ironic() +{ + local cur prev nbc cflags + COMPREPLY=() + cur="${COMP_WORDS[COMP_CWORD]}" + prev="${COMP_WORDS[COMP_CWORD-1]}" + + if [ "x$_ironic_opts" == "x" ] ; then + nbc="`ironic bash-completion | sed -e "s/ *-h */ /" -e "s/ *-i */ /"`" + _ironic_opts="`echo "$nbc" | sed -e "s/--[a-z0-9_-]*//g" -e "s/ */ /g"`" + _ironic_flags="`echo " $nbc" | sed -e "s/ [^-][^-][a-z0-9_-]*//g" -e "s/ */ /g"`" + _ironic_opts_exp="`echo "$_ironic_opts" | tr ' ' '|'`" + fi + + if [[ " ${COMP_WORDS[@]} " =~ " "($_ironic_opts_exp)" " && "$prev" != "help" ]] ; then + COMPLETION_CACHE=$HOME/.cache/python-ironicclient/*/*-cache + cflags="$_ironic_flags "$(cat $COMPLETION_CACHE 2> /dev/null | tr '\n' ' ') + COMPREPLY=($(compgen -W "${cflags}" -- ${cur})) + else + COMPREPLY=($(compgen -W "${_ironic_opts}" -- ${cur})) + fi + return 0 +} +complete -F _ironic ironic |
