Files
update/software-client/service-files/software_client.completion
Luis Eduardo Bonatti da6fa5d726 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>
2024-10-14 03:25:34 +00:00

59 lines
1.9 KiB
Plaintext

#
# Copyright (c) 2024 Wind River Systems, Inc.
#
# SPDX-License-Identifier: Apache-2.0
#
#
# This file provides bash-completion functionality for
# the unified software management CLI
#
_software_opts="" # lazy init
_software_flags="" # lazy init
_software_deploy_opts="" # lazy init
_software_deploy_flags="" # lazy init
_software_opts_exp="" # lazy init
_software()
{
local cur prev cmd kbc
COMPREPLY=()
cur="${COMP_WORDS[COMP_CWORD]}"
prev="${COMP_WORDS[COMP_CWORD-1]}"
cmd="${COMP_WORDS[1]}"
if [ "x$_software_opts" == "x" ] ; then
kbc="`software bash-completion | sed -e "s/ -h / /"`"
_software_opts="`echo "$kbc" | sed -e "s/--[a-z0-9_-]*//g" -e "s/[ ][ ]*/ /g"`"
_software_flags="`echo " $kbc" | sed -e "s/ [^-][^-][a-z0-9_-]*//g" -e "s/[ ][ ]*/ /g"`"
_software_opts_exp="`echo $_software_opts | sed -e "s/[ ]/|/g"`"
fi
if [ "x$_software_deploy_opts" == "x" ] && [ "$cmd" == "deploy" ] ; then
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"`"
fi
if [ "$cmd" == "deploy" ] ; then
if [[ " ${_software_deploy_opts} " == *" $prev "* && "$prev" != "help" ]] ; then
COMPREPLY=($(compgen -W "${_software_deploy_flags}" -- ${cur}))
else
COMPREPLY=($(compgen -W "${_software_deploy_opts}" -- ${cur}))
fi
else
if [[ " ${COMP_WORDS[@]} " =~ " "$_software_opts_exp" " && "$prev" != "help" ]] ; then
COMPREPLY=($(compgen -W "${_software_flags}" -- ${cur}))
else
COMPREPLY=($(compgen -W "${_software_opts}" -- ${cur}))
fi
fi
return 0
}
complete -F _software software