add nova-manage bash completion script
Change-Id: I856349fb0b31f32ec4570c74ebceb3563fa22547
This commit is contained in:
parent
8637f71e27
commit
38c98c4df5
1
Authors
1
Authors
@ -58,6 +58,7 @@ Devdeep Singh <devdeep.singh@citrix.com>
|
|||||||
Devendra Modium <dmodium@isi.edu>
|
Devendra Modium <dmodium@isi.edu>
|
||||||
Devin Carlen <devin.carlen@gmail.com>
|
Devin Carlen <devin.carlen@gmail.com>
|
||||||
Dina Belova <dbelova@mirantis.com>
|
Dina Belova <dbelova@mirantis.com>
|
||||||
|
Dominik Heidler <dheidler@suse.de>
|
||||||
Don Dugger <donald.d.dugger@intel.com>
|
Don Dugger <donald.d.dugger@intel.com>
|
||||||
Donal Lafferty <donal.lafferty@citrix.com>
|
Donal Lafferty <donal.lafferty@citrix.com>
|
||||||
Dong-In David Kang <dkang@isi.edu>
|
Dong-In David Kang <dkang@isi.edu>
|
||||||
|
@ -1692,6 +1692,18 @@ def main():
|
|||||||
print "\t%s" % k
|
print "\t%s" % k
|
||||||
sys.exit(2)
|
sys.exit(2)
|
||||||
category = argv.pop(0)
|
category = argv.pop(0)
|
||||||
|
if category == "bash-completion":
|
||||||
|
if len(argv) < 1:
|
||||||
|
print " ".join([k for (k, v) in CATEGORIES])
|
||||||
|
else:
|
||||||
|
query_category = argv.pop(0)
|
||||||
|
matches = lazy_match(query_category, CATEGORIES)
|
||||||
|
# instantiate the command group object
|
||||||
|
category, fn = matches[0]
|
||||||
|
command_object = fn()
|
||||||
|
actions = methods_of(command_object)
|
||||||
|
print " ".join([k for (k, v) in actions])
|
||||||
|
sys.exit(0)
|
||||||
matches = lazy_match(category, CATEGORIES)
|
matches = lazy_match(category, CATEGORIES)
|
||||||
# instantiate the command group object
|
# instantiate the command group object
|
||||||
category, fn = matches[0]
|
category, fn = matches[0]
|
||||||
|
37
tools/nova-manage.bash_completion
Normal file
37
tools/nova-manage.bash_completion
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
# bash completion for openstack nova-manage
|
||||||
|
|
||||||
|
_nova_manage_opts="" # lazy init
|
||||||
|
_nova_manage_opts_exp="" # lazy init
|
||||||
|
|
||||||
|
# dict hack for bash 3
|
||||||
|
_set_nova_manage_subopts () {
|
||||||
|
eval _nova_manage_subopts_"$1"='$2'
|
||||||
|
}
|
||||||
|
_get_nova_manage_subopts () {
|
||||||
|
eval echo '${_nova_manage_subopts_'"$1"'#_nova_manage_subopts_}'
|
||||||
|
}
|
||||||
|
|
||||||
|
_nova_manage()
|
||||||
|
{
|
||||||
|
local cur prev subopts
|
||||||
|
COMPREPLY=()
|
||||||
|
cur="${COMP_WORDS[COMP_CWORD]}"
|
||||||
|
prev="${COMP_WORDS[COMP_CWORD-1]}"
|
||||||
|
|
||||||
|
if [ "x$_nova_manage_opts" == "x" ] ; then
|
||||||
|
_nova_manage_opts="`nova-manage bash-completion 2>/dev/null`"
|
||||||
|
_nova_manage_opts_exp="`echo $_nova_manage_opts | sed -e "s/\s/|/g"`"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ " `echo $_nova_manage_opts` " =~ " $prev " ]] ; then
|
||||||
|
if [ "x$(_get_nova_manage_subopts "$prev")" == "x" ] ; then
|
||||||
|
subopts="`nova-manage bash-completion $prev 2>/dev/null`"
|
||||||
|
_set_nova_manage_subopts "$prev" "$subopts"
|
||||||
|
fi
|
||||||
|
COMPREPLY=($(compgen -W "$(_get_nova_manage_subopts "$prev")" -- ${cur}))
|
||||||
|
elif [[ ! " ${COMP_WORDS[@]} " =~ " "($_nova_manage_opts_exp)" " ]] ; then
|
||||||
|
COMPREPLY=($(compgen -W "${_nova_manage_opts}" -- ${cur}))
|
||||||
|
fi
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
complete -F _nova_manage nova-manage
|
Loading…
Reference in New Issue
Block a user