e4963ea278
A script to be used for bash completion of murano CLI tool commands. Change-Id: Id50ece6b360832601eefdb9b118c646dcaebcfc5 Implements: blueprint murano-bash-completion-script
27 lines
873 B
Plaintext
27 lines
873 B
Plaintext
_murano_opts="" # lazy init
|
|
_murano_flags="" # lazy init
|
|
_murano_opts_exp="" # lazy init
|
|
_murano()
|
|
{
|
|
local cur prev kbc
|
|
COMPREPLY=()
|
|
cur="${COMP_WORDS[COMP_CWORD]}"
|
|
prev="${COMP_WORDS[COMP_CWORD-1]}"
|
|
|
|
if [ "x$_murano_opts" == "x" ] ; then
|
|
kbc="$(murano bash-completion | sed -e "s/ -h / /")"
|
|
_murano_opts="$(echo "$kbc" | sed -e "s/--[a-z0-9_-]*//g" -e "s/[ ][ ]*/ /g")"
|
|
_murano_flags="$(echo " $kbc" | sed -e "s/ [^-][^-][a-z0-9_-]*//g" -e "s/[ ][ ]*/ /g")"
|
|
_murano_opts_exp="$(echo "$_murano_opts" | sed -e "s/[ ]/|/g")"
|
|
fi
|
|
|
|
if [[ " ${COMP_WORDS[@]} " =~ " "($_murano_opts_exp)" " && "$prev" != "help" ]] ; then
|
|
COMPREPLY=($(compgen -W "${_murano_flags}" -- "${cur}"))
|
|
else
|
|
COMPREPLY=($(compgen -W "${_murano_opts}" -- "${cur}"))
|
|
fi
|
|
return 0
|
|
}
|
|
complete -o default -F _murano murano
|
|
|