python-glareclient/tools/glance.bash_completion
Darja Malyavkina 6005eb8b3b Glare client code
Taken from https://github.com/dshakhray/python-glareclient

Change-Id: If0e7e5cd0e39281f725df21308a18ed6caa8a009
2016-09-12 14:24:03 +03:00

25 lines
867 B
Plaintext

_glare_opts="" # lazy init
_glare_flags="" # lazy init
_glare_opts_exp="" # lazy init
_glare()
{
local cur prev nbc cflags
COMPREPLY=()
cur="${COMP_WORDS[COMP_CWORD]}"
prev="${COMP_WORDS[COMP_CWORD-1]}"
if [ "x$_glare_opts" == "x" ] ; then
nbc="`glare bash-completion | sed -e "s/ *-h */ /" -e "s/ *-i */ /"`"
_glare_opts="`echo "$nbc" | sed -e "s/--[a-z0-9_-]*//g" -e "s/ */ /g"`"
_glare_flags="`echo " $nbc" | sed -e "s/ [^-][^-][a-z0-9_-]*//g" -e "s/ */ /g"`"
_glare_opts_exp="`echo "$_glare_opts" | sed 's/^ *//' | tr ' ' '|'`"
fi
if [[ " ${COMP_WORDS[@]} " =~ " "($_glare_opts_exp)" " && "$prev" != "help" ]] ; then
COMPREPLY=($(compgen -W "${_glare_flags}" -- ${cur}))
else
COMPREPLY=($(compgen -W "${_glare_opts}" -- ${cur}))
fi
return 0
}
complete -F _glare glare