From 7a16eda8adfe5d85f037c0e1b1fb5308c4c990c8 Mon Sep 17 00:00:00 2001 From: Martin Winkler Date: Thu, 21 Apr 2022 22:41:58 +0200 Subject: [PATCH] sqn-completion - also complete available profiles (-p) --- sqn-completion.bash | 31 +++++++++++++++++++++++++------ 1 file changed, 25 insertions(+), 6 deletions(-) diff --git a/sqn-completion.bash b/sqn-completion.bash index 498290f..dd3dca1 100755 --- a/sqn-completion.bash +++ b/sqn-completion.bash @@ -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 }