2014-12-05 23:49:42 +05:30
|
|
|
_cinder_opts="" # lazy init
|
|
|
|
_cinder_flags="" # lazy init
|
|
|
|
_cinder_opts_exp="" # lazy init
|
|
|
|
|
2012-05-21 16:32:35 -04:00
|
|
|
_cinder()
|
|
|
|
{
|
2014-12-05 23:49:42 +05:30
|
|
|
local cur prev cbc cflags
|
2012-05-21 16:32:35 -04:00
|
|
|
COMPREPLY=()
|
|
|
|
cur="${COMP_WORDS[COMP_CWORD]}"
|
|
|
|
prev="${COMP_WORDS[COMP_CWORD-1]}"
|
|
|
|
|
2014-12-05 23:49:42 +05:30
|
|
|
if [ "x$_cinder_opts" == "x" ] ; then
|
|
|
|
cbc="`cinder bash-completion | sed -e "s/ *-h */ /" -e "s/ *-i */ /"`"
|
|
|
|
_cinder_opts="`echo "$cbc" | sed -e "s/--[a-z0-9_-]*//g" -e "s/ */ /g"`"
|
|
|
|
_cinder_flags="`echo " $cbc" | sed -e "s/ [^-][^-][a-z0-9_-]*//g" -e "s/ */ /g"`"
|
|
|
|
fi
|
2012-05-21 16:32:35 -04:00
|
|
|
|
2014-12-05 23:49:42 +05:30
|
|
|
if [[ "$prev" != "help" ]] ; then
|
|
|
|
COMPLETION_CACHE=~/.cinderclient/*/*-cache
|
|
|
|
cflags="$_cinder_flags $_cinder_opts "$(cat $COMPLETION_CACHE 2> /dev/null | tr '\n' ' ')
|
|
|
|
COMPREPLY=($(compgen -W "${cflags}" -- ${cur}))
|
|
|
|
else
|
|
|
|
COMPREPLY=($(compgen -W "${_cinder_opts}" -- ${cur}))
|
|
|
|
fi
|
|
|
|
return 0
|
2012-05-21 16:32:35 -04:00
|
|
|
}
|
|
|
|
complete -F _cinder cinder
|