1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39
|
# shellcheck disable=SC2148
# No hashbang for bash completion scripts! They are intended to be sourced, not executed.
_km-config_completions()
{
local cur prev opts
COMPREPLY=()
cur="${COMP_WORDS[COMP_CWORD]}"
prev="${COMP_WORDS[COMP_CWORD-1]}"
opts="-h --help -v --verbose -vv --veryverbose --version -i --install"
if [[ ${cur} == -* ]] ; then
# shellcheck disable=SC2207
COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
return 0
fi
# default IFS splits 'file://' into 'file', ':' and '//'
if [ "${prev}" == ":" ] && [ "${COMP_WORDS[COMP_CWORD-2]}" == "file" ]; then
local flag=${COMP_WORDS[COMP_CWORD-3]}
if [ "$flag" == "-i" ] || [ "$flag" == "--install" ]; then
prev=$flag
fi
fi
case "${prev}" in
"-i"|"--install")
local IFS=$'\n'
compopt -o filenames
# shellcheck disable=SC2207
COMPREPLY=( $(compgen -f -X "!"*.kmp -- "$cur") $(compgen -d -- "$cur") )
return 0
;;
*)
;;
esac
}
complete -F _km-config_completions km-config
|