Added bash completion script

Change-Id: I4faa380ee013b27755eeb49abed0cdbfbd1485d9
This commit is contained in:
aviau 2014-12-22 10:34:45 -05:00
parent 12736650dc
commit 037303d8bc

View File

@ -0,0 +1,27 @@
# bash completion for openstack surveil
_surveil_opts="" # lazy init
_surveil_flags="" # lazy init
_surveil_opts_exp="" # lazy init
_surveil()
{
local cur prev kbc
COMPREPLY=()
cur="${COMP_WORDS[COMP_CWORD]}"
prev="${COMP_WORDS[COMP_CWORD-1]}"
if [ "x$_surveil_opts" == "x" ] ; then
kbc="`surveil bash-completion | sed -e "s/ -h / /"`"
_surveil_opts="`echo "$kbc" | sed -e "s/--[a-z0-9_-]*//g" -e "s/[ ][ ]*/ /g"`"
_surveil_flags="`echo " $kbc" | sed -e "s/ [^-][^-][a-z0-9_-]*//g" -e "s/[ ][ ]*/ /g"`"
_surveil_opts_exp="`echo $_surveil_opts | sed -e "s/[ ]/|/g"`"
fi
if [[ " ${COMP_WORDS[@]} " =~ " "($_surveil_opts_exp)" " && "$prev" != "help" ]] ; then
COMPREPLY=($(compgen -W "${_surveil_flags}" -- ${cur}))
else
COMPREPLY=($(compgen -W "${_surveil_opts}" -- ${cur}))
fi
return 0
}
complete -o default -F _surveil surveil