34 lines
1002 B
Plaintext
34 lines
1002 B
Plaintext
#
|
|
# Copyright (c) 2013-2017 Wind River Systems, Inc.
|
|
#
|
|
# SPDX-License-Identifier: Apache-2.0
|
|
#
|
|
|
|
# bash completion for Titanium Cloud system commands
|
|
|
|
_system_opts="" # lazy init
|
|
_system_flags="" # lazy init
|
|
_system_opts_exp="" # lazy init
|
|
_system()
|
|
{
|
|
local cur prev kbc
|
|
COMPREPLY=()
|
|
cur="${COMP_WORDS[COMP_CWORD]}"
|
|
prev="${COMP_WORDS[COMP_CWORD-1]}"
|
|
|
|
if [ "x$_system_opts" == "x" ] ; then
|
|
kbc="`system bash-completion | sed -e "s/ -h / /"`"
|
|
_system_opts="`echo "$kbc" | sed -e "s/--[a-z0-9_-]*//g" -e "s/[ ][ ]*/ /g"`"
|
|
_system_flags="`echo " $kbc" | sed -e "s/ [^-][^-][a-z0-9_-]*//g" -e "s/[ ][ ]*/ /g"`"
|
|
_system_opts_exp="`echo $_system_opts | sed -e "s/[ ]/|/g"`"
|
|
fi
|
|
|
|
if [[ " ${COMP_WORDS[@]} " =~ " "($_system_opts_exp)" " && "$prev" != "help" ]] ; then
|
|
COMPREPLY=($(compgen -W "${_system_flags}" -- ${cur}))
|
|
else
|
|
COMPREPLY=($(compgen -W "${_system_opts}" -- ${cur}))
|
|
fi
|
|
return 0
|
|
}
|
|
complete -F _system system
|