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