Fix software deploy subcommand completion
This commit fix the current behavior of software bash completion which was not completing for the software deploy subcommand. PASS: Software deploy <tab><tab> list all options. PASS: Software deploy st<tab> completes with 'start'. PASS: Software deploy start <tab><tab> list flags. Story: 2010676 Task: 51162 Change-Id: Icfcddbe861a1f0eeb309e3d0e105bdd3989cb768 Signed-off-by: Luis Eduardo Bonatti <luizeduardo.bonatti@windriver.com>
This commit is contained in:
@@ -35,11 +35,11 @@ _software()
|
||||
kbc="`software deploy bash-completion | sed -e "s/ -h / /"`"
|
||||
_software_deploy_opts="`echo "$kbc" | sed -e "s/--[a-z0-9_-]*//g" -e "s/[ ][ ]*/ /g"`"
|
||||
_software_deploy_flags="`echo " $kbc" | sed -e "s/ [^-][^-][a-z0-9_-]*//g" -e "s/[ ][ ]*/ /g"`"
|
||||
_software_deploy_opts_exp="`echo $_software_deploy_opts | sed -e "s/[ ]/|/g"`"
|
||||
_software_deploy_opts_exp="`echo $_software_deploy_opts | sed -e "s/[ ]\+/|/g"`"
|
||||
fi
|
||||
|
||||
if [ "$cmd" == "deploy" ] ; then
|
||||
if [[ " ${COMP_WORDS[@]} " =~ " "$_software_deploy_opts_exp" " && "$prev" != "help" ]] ; then
|
||||
if [[ " ${_software_deploy_opts} " == *" $prev "* && "$prev" != "help" ]] ; then
|
||||
COMPREPLY=($(compgen -W "${_software_deploy_flags}" -- ${cur}))
|
||||
else
|
||||
COMPREPLY=($(compgen -W "${_software_deploy_opts}" -- ${cur}))
|
||||
|
@@ -405,14 +405,16 @@ class SoftwareClientShell(object):
|
||||
deploy_options = set()
|
||||
software_deploy_command = "software deploy"
|
||||
deploy_command = "deploy"
|
||||
unlisted_commands = [deploy_command, "bash-completion", "bash_completion"]
|
||||
unlisted_commands = ["bash-completion", "bash_completion"]
|
||||
|
||||
for sc_str, sc in self.subcommands.items():
|
||||
# Separate between software command and deploy commands
|
||||
if sc.prog.startswith(software_deploy_command):
|
||||
if sc_str in unlisted_commands:
|
||||
continue
|
||||
deploy_commands.add(sc_str)
|
||||
# Remove deploy prefix output
|
||||
opt = sc_str[len(f"{deploy_command} "):]
|
||||
deploy_commands.add(opt)
|
||||
for option in list(sc._optionals._option_string_actions):
|
||||
deploy_options.add(option)
|
||||
else:
|
||||
|
Reference in New Issue
Block a user