sqn-completion - also complete available profiles (-p)

This commit is contained in:
2022-04-21 22:41:58 +02:00
parent 1dfe86e69b
commit 7a16eda8ad

View File

@@ -13,9 +13,9 @@ _sqn_completions()
curCmd="${curCmd%\"\'*}"
COMPREPLY=()
case "$cur" in
-*)
-*|+*)
opts=( \
-- \
-- ++\
-a --all \
-c --config \
-d --dry-run \
@@ -31,10 +31,29 @@ _sqn_completions()
--version)
read -r -d '' -a COMPREPLY < <(compgen -W "${opts[*]}" -- "$cur");;
*)
# Stop after step selection (last argument which is not an option; starting with "-")
(( COMP_CWORD > 1 )) && [[ ! "${COMP_WORDS[((COMP_CWORD - 1))]}" =~ ^- ]] && return
# sequencer.sh provides creation of a step list with search functionality
read -r -a COMPREPLY <<<"$( "$curCmd" -ls "$cur" )";;
case "${COMP_WORDS[((COMP_CWORD-1))]}" in
# provide completion for option with parameter
-p|--profile)
# sequencer.sh provides creation of a profile list with search functionality
read -r -a COMPREPLY <<<"$( "$curCmd" -pl "${cur}" )"
;;
*)
# Stop after step selection (last argument which is not an option (starting with "-|+")
# or option paramter (profile name))
if (( COMP_CWORD > 1 )) && [[ ! "${COMP_WORDS[((COMP_CWORD - 1))]}" =~ ^(-|\+) ]] ; then
case "${COMP_WORDS[((COMP_CWORD - 2))]}" in
-p|--profile)
;;
*)
return
;;
esac
fi
# sequencer.sh provides creation of a step list with search functionality
read -r -a COMPREPLY <<<"$( "$curCmd" -ls "$cur" )"
;;
esac
;;
esac
return 0
}