diff --git a/Runfile b/Runfile index bac19fe..70349b0 100644 --- a/Runfile +++ b/Runfile @@ -24,3 +24,9 @@ action :schema do end end +help 'Run preconfigured shfmt on any script' +usage 'shfmt SCRIPT' +action :shfmt do |args| + system "shfmt -d -i 2 -ci #{args['SCRIPT']}" + say $?.success? ? 'g`PASS`' : 'r`FAIL`' +end diff --git a/lib/completely/installer.rb b/lib/completely/installer.rb index ae80323..f4eebdf 100644 --- a/lib/completely/installer.rb +++ b/lib/completely/installer.rb @@ -4,8 +4,8 @@ class << self def from_io(program:, io: nil) io ||= $stdin - raise InstallError, "io must respond to #read" unless io.respond_to?(:read) - raise InstallError, "io is closed" if io.respond_to?(:closed?) && io.closed? + raise InstallError, 'io must respond to #read' unless io.respond_to?(:read) + raise InstallError, 'io is closed' if io.respond_to?(:closed?) && io.closed? from_string program:, string: io.read end @@ -23,7 +23,7 @@ def from_string(program:, string:) end def create_tempfile - tempfile = Tempfile.new ["completely-", '.bash'] + tempfile = Tempfile.new ['completely-', '.bash'] tempfiles.push tempfile tempfile end diff --git a/lib/completely/templates/template.erb b/lib/completely/templates/template.erb index 53d097c..b5dfbe4 100644 --- a/lib/completely/templates/template.erb +++ b/lib/completely/templates/template.erb @@ -9,24 +9,46 @@ local cur=${COMP_WORDS[COMP_CWORD]} local result=() + # words the user already typed (excluding the command itself) + local used=() + if ((COMP_CWORD > 1)); then + used=("${COMP_WORDS[@]:1:$((COMP_CWORD - 1))}") + fi + if [[ "${cur:0:1}" == "-" ]]; then + # Completing an option: offer everything (including options) echo "$words" else + # Completing a non-option: offer only non-options, + # and don't re-offer ones already used earlier in the line. for word in $words; do - [[ "${word:0:1}" != "-" ]] && result+=("$word") + [[ "${word:0:1}" == "-" ]] && continue + + local seen=0 + for u in "${used[@]}"; do + if [[ "$u" == "$word" ]]; then + seen=1 + break + fi + done + ((!seen)) && result+=("$word") done echo "${result[*]}" - fi } <%= function_name %>() { local cur=${COMP_WORDS[COMP_CWORD]} - local compwords=("${COMP_WORDS[@]:1:$COMP_CWORD-1}") + local compwords=() + if ((COMP_CWORD > 0)); then + compwords=("${COMP_WORDS[@]:1:$((COMP_CWORD - 1))}") + fi local compline="${compwords[*]}" + COMPREPLY=() + % if ENV['COMPLETELY_DEBUG'] if [[ -n "$COMPLETELY_DEBUG" ]]; then echo "compline: '$compline'" > 'completely-debug.txt' diff --git a/spec/approvals/cli/generated-script b/spec/approvals/cli/generated-script index 5b866d8..94e256e 100644 --- a/spec/approvals/cli/generated-script +++ b/spec/approvals/cli/generated-script @@ -9,24 +9,46 @@ _mygit_completions_filter() { local cur=${COMP_WORDS[COMP_CWORD]} local result=() + # words the user already typed (excluding the command itself) + local used=() + if ((COMP_CWORD > 1)); then + used=("${COMP_WORDS[@]:1:$((COMP_CWORD - 1))}") + fi + if [[ "${cur:0:1}" == "-" ]]; then + # Completing an option: offer everything (including options) echo "$words" else + # Completing a non-option: offer only non-options, + # and don't re-offer ones already used earlier in the line. for word in $words; do - [[ "${word:0:1}" != "-" ]] && result+=("$word") + [[ "${word:0:1}" == "-" ]] && continue + + local seen=0 + for u in "${used[@]}"; do + if [[ "$u" == "$word" ]]; then + seen=1 + break + fi + done + ((!seen)) && result+=("$word") done echo "${result[*]}" - fi } _mygit_completions() { local cur=${COMP_WORDS[COMP_CWORD]} - local compwords=("${COMP_WORDS[@]:1:$COMP_CWORD-1}") + local compwords=() + if ((COMP_CWORD > 0)); then + compwords=("${COMP_WORDS[@]:1:$((COMP_CWORD - 1))}") + fi local compline="${compwords[*]}" + COMPREPLY=() + case "$compline" in 'status'*'--branch') while read -r; do COMPREPLY+=("$REPLY"); done < <(compgen -W "$(_mygit_completions_filter "$(git branch --format='%(refname:short)' 2>/dev/null)")" -- "$cur") diff --git a/spec/approvals/cli/generated-script-alt b/spec/approvals/cli/generated-script-alt index 789149f..217aae4 100644 --- a/spec/approvals/cli/generated-script-alt +++ b/spec/approvals/cli/generated-script-alt @@ -9,24 +9,46 @@ _mycomps_filter() { local cur=${COMP_WORDS[COMP_CWORD]} local result=() + # words the user already typed (excluding the command itself) + local used=() + if ((COMP_CWORD > 1)); then + used=("${COMP_WORDS[@]:1:$((COMP_CWORD - 1))}") + fi + if [[ "${cur:0:1}" == "-" ]]; then + # Completing an option: offer everything (including options) echo "$words" else + # Completing a non-option: offer only non-options, + # and don't re-offer ones already used earlier in the line. for word in $words; do - [[ "${word:0:1}" != "-" ]] && result+=("$word") + [[ "${word:0:1}" == "-" ]] && continue + + local seen=0 + for u in "${used[@]}"; do + if [[ "$u" == "$word" ]]; then + seen=1 + break + fi + done + ((!seen)) && result+=("$word") done echo "${result[*]}" - fi } _mycomps() { local cur=${COMP_WORDS[COMP_CWORD]} - local compwords=("${COMP_WORDS[@]:1:$COMP_CWORD-1}") + local compwords=() + if ((COMP_CWORD > 0)); then + compwords=("${COMP_WORDS[@]:1:$((COMP_CWORD - 1))}") + fi local compline="${compwords[*]}" + COMPREPLY=() + case "$compline" in 'status'*'--branch') while read -r; do COMPREPLY+=("$REPLY"); done < <(compgen -W "$(_mycomps_filter "$(git branch --format='%(refname:short)' 2>/dev/null)")" -- "$cur") diff --git a/spec/approvals/cli/generated-wrapped-script b/spec/approvals/cli/generated-wrapped-script index a788dd1..e37ade0 100644 --- a/spec/approvals/cli/generated-wrapped-script +++ b/spec/approvals/cli/generated-wrapped-script @@ -10,24 +10,46 @@ give_comps() { echo $' local cur=${COMP_WORDS[COMP_CWORD]}' echo $' local result=()' echo $'' + echo $' # words the user already typed (excluding the command itself)' + echo $' local used=()' + echo $' if ((COMP_CWORD > 1)); then' + echo $' used=("${COMP_WORDS[@]:1:$((COMP_CWORD - 1))}")' + echo $' fi' + echo $'' echo $' if [[ "${cur:0:1}" == "-" ]]; then' + echo $' # Completing an option: offer everything (including options)' echo $' echo "$words"' echo $'' echo $' else' + echo $' # Completing a non-option: offer only non-options,' + echo $' # and don\'t re-offer ones already used earlier in the line.' echo $' for word in $words; do' - echo $' [[ "${word:0:1}" != "-" ]] && result+=("$word")' + echo $' [[ "${word:0:1}" == "-" ]] && continue' + echo $'' + echo $' local seen=0' + echo $' for u in "${used[@]}"; do' + echo $' if [[ "$u" == "$word" ]]; then' + echo $' seen=1' + echo $' break' + echo $' fi' + echo $' done' + echo $' ((!seen)) && result+=("$word")' echo $' done' echo $'' echo $' echo "${result[*]}"' - echo $'' echo $' fi' echo $'}' echo $'' echo $'_mygit_completions() {' echo $' local cur=${COMP_WORDS[COMP_CWORD]}' - echo $' local compwords=("${COMP_WORDS[@]:1:$COMP_CWORD-1}")' + echo $' local compwords=()' + echo $' if ((COMP_CWORD > 0)); then' + echo $' compwords=("${COMP_WORDS[@]:1:$((COMP_CWORD - 1))}")' + echo $' fi' echo $' local compline="${compwords[*]}"' echo $'' + echo $' COMPREPLY=()' + echo $'' echo $' case "$compline" in' echo $' \'status\'*\'--branch\')' echo $' while read -r; do COMPREPLY+=("$REPLY"); done < <(compgen -W "$(_mygit_completions_filter "$(git branch --format=\'%(refname:short)\' 2>/dev/null)")" -- "$cur")' diff --git a/spec/approvals/cli/test/completely-tester-1.sh b/spec/approvals/cli/test/completely-tester-1.sh index b538012..50d5b48 100644 --- a/spec/approvals/cli/test/completely-tester-1.sh +++ b/spec/approvals/cli/test/completely-tester-1.sh @@ -17,24 +17,46 @@ _mygit_completions_filter() { local cur=${COMP_WORDS[COMP_CWORD]} local result=() + # words the user already typed (excluding the command itself) + local used=() + if ((COMP_CWORD > 1)); then + used=("${COMP_WORDS[@]:1:$((COMP_CWORD - 1))}") + fi + if [[ "${cur:0:1}" == "-" ]]; then + # Completing an option: offer everything (including options) echo "$words" else + # Completing a non-option: offer only non-options, + # and don't re-offer ones already used earlier in the line. for word in $words; do - [[ "${word:0:1}" != "-" ]] && result+=("$word") + [[ "${word:0:1}" == "-" ]] && continue + + local seen=0 + for u in "${used[@]}"; do + if [[ "$u" == "$word" ]]; then + seen=1 + break + fi + done + ((!seen)) && result+=("$word") done echo "${result[*]}" - fi } _mygit_completions() { local cur=${COMP_WORDS[COMP_CWORD]} - local compwords=("${COMP_WORDS[@]:1:$COMP_CWORD-1}") + local compwords=() + if ((COMP_CWORD > 0)); then + compwords=("${COMP_WORDS[@]:1:$((COMP_CWORD - 1))}") + fi local compline="${compwords[*]}" + COMPREPLY=() + case "$compline" in 'status'*'--branch') while read -r; do COMPREPLY+=("$REPLY"); done < <(compgen -W "$(_mygit_completions_filter "$(git branch --format='%(refname:short)' 2>/dev/null)")" -- "$cur") diff --git a/spec/approvals/cli/test/completely-tester-2.sh b/spec/approvals/cli/test/completely-tester-2.sh index 4d7f4d5..a0fb1e3 100644 --- a/spec/approvals/cli/test/completely-tester-2.sh +++ b/spec/approvals/cli/test/completely-tester-2.sh @@ -17,24 +17,46 @@ _mygit_completions_filter() { local cur=${COMP_WORDS[COMP_CWORD]} local result=() + # words the user already typed (excluding the command itself) + local used=() + if ((COMP_CWORD > 1)); then + used=("${COMP_WORDS[@]:1:$((COMP_CWORD - 1))}") + fi + if [[ "${cur:0:1}" == "-" ]]; then + # Completing an option: offer everything (including options) echo "$words" else + # Completing a non-option: offer only non-options, + # and don't re-offer ones already used earlier in the line. for word in $words; do - [[ "${word:0:1}" != "-" ]] && result+=("$word") + [[ "${word:0:1}" == "-" ]] && continue + + local seen=0 + for u in "${used[@]}"; do + if [[ "$u" == "$word" ]]; then + seen=1 + break + fi + done + ((!seen)) && result+=("$word") done echo "${result[*]}" - fi } _mygit_completions() { local cur=${COMP_WORDS[COMP_CWORD]} - local compwords=("${COMP_WORDS[@]:1:$COMP_CWORD-1}") + local compwords=() + if ((COMP_CWORD > 0)); then + compwords=("${COMP_WORDS[@]:1:$((COMP_CWORD - 1))}") + fi local compline="${compwords[*]}" + COMPREPLY=() + case "$compline" in 'status'*'--branch') while read -r; do COMPREPLY+=("$REPLY"); done < <(compgen -W "$(_mygit_completions_filter "$(git branch --format='%(refname:short)' 2>/dev/null)")" -- "$cur") diff --git a/spec/approvals/cli/test/completely-tester.sh b/spec/approvals/cli/test/completely-tester.sh index 2633b8b..108dbf9 100644 --- a/spec/approvals/cli/test/completely-tester.sh +++ b/spec/approvals/cli/test/completely-tester.sh @@ -17,24 +17,46 @@ _mygit_completions_filter() { local cur=${COMP_WORDS[COMP_CWORD]} local result=() + # words the user already typed (excluding the command itself) + local used=() + if ((COMP_CWORD > 1)); then + used=("${COMP_WORDS[@]:1:$((COMP_CWORD - 1))}") + fi + if [[ "${cur:0:1}" == "-" ]]; then + # Completing an option: offer everything (including options) echo "$words" else + # Completing a non-option: offer only non-options, + # and don't re-offer ones already used earlier in the line. for word in $words; do - [[ "${word:0:1}" != "-" ]] && result+=("$word") + [[ "${word:0:1}" == "-" ]] && continue + + local seen=0 + for u in "${used[@]}"; do + if [[ "$u" == "$word" ]]; then + seen=1 + break + fi + done + ((!seen)) && result+=("$word") done echo "${result[*]}" - fi } _mygit_completions() { local cur=${COMP_WORDS[COMP_CWORD]} - local compwords=("${COMP_WORDS[@]:1:$COMP_CWORD-1}") + local compwords=() + if ((COMP_CWORD > 0)); then + compwords=("${COMP_WORDS[@]:1:$((COMP_CWORD - 1))}") + fi local compline="${compwords[*]}" + COMPREPLY=() + case "$compline" in 'status'*'--branch') while read -r; do COMPREPLY+=("$REPLY"); done < <(compgen -W "$(_mygit_completions_filter "$(git branch --format='%(refname:short)' 2>/dev/null)")" -- "$cur") diff --git a/spec/approvals/completions/function b/spec/approvals/completions/function index 9c62787..1b31b34 100644 --- a/spec/approvals/completions/function +++ b/spec/approvals/completions/function @@ -10,24 +10,46 @@ send_completions() { echo $' local cur=${COMP_WORDS[COMP_CWORD]}' echo $' local result=()' echo $'' + echo $' # words the user already typed (excluding the command itself)' + echo $' local used=()' + echo $' if ((COMP_CWORD > 1)); then' + echo $' used=("${COMP_WORDS[@]:1:$((COMP_CWORD - 1))}")' + echo $' fi' + echo $'' echo $' if [[ "${cur:0:1}" == "-" ]]; then' + echo $' # Completing an option: offer everything (including options)' echo $' echo "$words"' echo $'' echo $' else' + echo $' # Completing a non-option: offer only non-options,' + echo $' # and don\'t re-offer ones already used earlier in the line.' echo $' for word in $words; do' - echo $' [[ "${word:0:1}" != "-" ]] && result+=("$word")' + echo $' [[ "${word:0:1}" == "-" ]] && continue' + echo $'' + echo $' local seen=0' + echo $' for u in "${used[@]}"; do' + echo $' if [[ "$u" == "$word" ]]; then' + echo $' seen=1' + echo $' break' + echo $' fi' + echo $' done' + echo $' ((!seen)) && result+=("$word")' echo $' done' echo $'' echo $' echo "${result[*]}"' - echo $'' echo $' fi' echo $'}' echo $'' echo $'_completely_completions() {' echo $' local cur=${COMP_WORDS[COMP_CWORD]}' - echo $' local compwords=("${COMP_WORDS[@]:1:$COMP_CWORD-1}")' + echo $' local compwords=()' + echo $' if ((COMP_CWORD > 0)); then' + echo $' compwords=("${COMP_WORDS[@]:1:$((COMP_CWORD - 1))}")' + echo $' fi' echo $' local compline="${compwords[*]}"' echo $'' + echo $' COMPREPLY=()' + echo $'' echo $' case "$compline" in' echo $' \'generate\'*)' echo $' while read -r; do COMPREPLY+=("$REPLY"); done < <(compgen -A directory -W "$(_completely_completions_filter "--help --force")" -- "$cur")' diff --git a/spec/approvals/completions/script b/spec/approvals/completions/script index 32b7da3..cba794b 100644 --- a/spec/approvals/completions/script +++ b/spec/approvals/completions/script @@ -9,24 +9,46 @@ _completely_completions_filter() { local cur=${COMP_WORDS[COMP_CWORD]} local result=() + # words the user already typed (excluding the command itself) + local used=() + if ((COMP_CWORD > 1)); then + used=("${COMP_WORDS[@]:1:$((COMP_CWORD - 1))}") + fi + if [[ "${cur:0:1}" == "-" ]]; then + # Completing an option: offer everything (including options) echo "$words" else + # Completing a non-option: offer only non-options, + # and don't re-offer ones already used earlier in the line. for word in $words; do - [[ "${word:0:1}" != "-" ]] && result+=("$word") + [[ "${word:0:1}" == "-" ]] && continue + + local seen=0 + for u in "${used[@]}"; do + if [[ "$u" == "$word" ]]; then + seen=1 + break + fi + done + ((!seen)) && result+=("$word") done echo "${result[*]}" - fi } _completely_completions() { local cur=${COMP_WORDS[COMP_CWORD]} - local compwords=("${COMP_WORDS[@]:1:$COMP_CWORD-1}") + local compwords=() + if ((COMP_CWORD > 0)); then + compwords=("${COMP_WORDS[@]:1:$((COMP_CWORD - 1))}") + fi local compline="${compwords[*]}" + COMPREPLY=() + case "$compline" in 'generate'*) while read -r; do COMPREPLY+=("$REPLY"); done < <(compgen -A directory -W "$(_completely_completions_filter "--help --force")" -- "$cur") diff --git a/spec/approvals/completions/script-complete-options b/spec/approvals/completions/script-complete-options index df0c962..a0dff27 100644 --- a/spec/approvals/completions/script-complete-options +++ b/spec/approvals/completions/script-complete-options @@ -9,24 +9,46 @@ _mygit_completions_filter() { local cur=${COMP_WORDS[COMP_CWORD]} local result=() + # words the user already typed (excluding the command itself) + local used=() + if ((COMP_CWORD > 1)); then + used=("${COMP_WORDS[@]:1:$((COMP_CWORD - 1))}") + fi + if [[ "${cur:0:1}" == "-" ]]; then + # Completing an option: offer everything (including options) echo "$words" else + # Completing a non-option: offer only non-options, + # and don't re-offer ones already used earlier in the line. for word in $words; do - [[ "${word:0:1}" != "-" ]] && result+=("$word") + [[ "${word:0:1}" == "-" ]] && continue + + local seen=0 + for u in "${used[@]}"; do + if [[ "$u" == "$word" ]]; then + seen=1 + break + fi + done + ((!seen)) && result+=("$word") done echo "${result[*]}" - fi } _mygit_completions() { local cur=${COMP_WORDS[COMP_CWORD]} - local compwords=("${COMP_WORDS[@]:1:$COMP_CWORD-1}") + local compwords=() + if ((COMP_CWORD > 0)); then + compwords=("${COMP_WORDS[@]:1:$((COMP_CWORD - 1))}") + fi local compline="${compwords[*]}" + COMPREPLY=() + case "$compline" in *) while read -r; do COMPREPLY+=("$REPLY"); done < <(compgen -W "$(_mygit_completions_filter "status commit")" -- "$cur") diff --git a/spec/approvals/completions/script-only-spaces b/spec/approvals/completions/script-only-spaces index 65df1dc..44695a6 100644 --- a/spec/approvals/completions/script-only-spaces +++ b/spec/approvals/completions/script-only-spaces @@ -9,24 +9,46 @@ _completely_completions_filter() { local cur=${COMP_WORDS[COMP_CWORD]} local result=() + # words the user already typed (excluding the command itself) + local used=() + if ((COMP_CWORD > 1)); then + used=("${COMP_WORDS[@]:1:$((COMP_CWORD - 1))}") + fi + if [[ "${cur:0:1}" == "-" ]]; then + # Completing an option: offer everything (including options) echo "$words" else + # Completing a non-option: offer only non-options, + # and don't re-offer ones already used earlier in the line. for word in $words; do - [[ "${word:0:1}" != "-" ]] && result+=("$word") + [[ "${word:0:1}" == "-" ]] && continue + + local seen=0 + for u in "${used[@]}"; do + if [[ "$u" == "$word" ]]; then + seen=1 + break + fi + done + ((!seen)) && result+=("$word") done echo "${result[*]}" - fi } _completely_completions() { local cur=${COMP_WORDS[COMP_CWORD]} - local compwords=("${COMP_WORDS[@]:1:$COMP_CWORD-1}") + local compwords=() + if ((COMP_CWORD > 0)); then + compwords=("${COMP_WORDS[@]:1:$((COMP_CWORD - 1))}") + fi local compline="${compwords[*]}" + COMPREPLY=() + case "$compline" in 'generate'*) while read -r; do COMPREPLY+=("$REPLY"); done < <(compgen -A directory -W "$(_completely_completions_filter "--help --force")" -- "$cur") diff --git a/spec/approvals/completions/script-with-debug b/spec/approvals/completions/script-with-debug index 14c9911..afc0053 100644 --- a/spec/approvals/completions/script-with-debug +++ b/spec/approvals/completions/script-with-debug @@ -9,24 +9,46 @@ _completely_completions_filter() { local cur=${COMP_WORDS[COMP_CWORD]} local result=() + # words the user already typed (excluding the command itself) + local used=() + if ((COMP_CWORD > 1)); then + used=("${COMP_WORDS[@]:1:$((COMP_CWORD - 1))}") + fi + if [[ "${cur:0:1}" == "-" ]]; then + # Completing an option: offer everything (including options) echo "$words" else + # Completing a non-option: offer only non-options, + # and don't re-offer ones already used earlier in the line. for word in $words; do - [[ "${word:0:1}" != "-" ]] && result+=("$word") + [[ "${word:0:1}" == "-" ]] && continue + + local seen=0 + for u in "${used[@]}"; do + if [[ "$u" == "$word" ]]; then + seen=1 + break + fi + done + ((!seen)) && result+=("$word") done echo "${result[*]}" - fi } _completely_completions() { local cur=${COMP_WORDS[COMP_CWORD]} - local compwords=("${COMP_WORDS[@]:1:$COMP_CWORD-1}") + local compwords=() + if ((COMP_CWORD > 0)); then + compwords=("${COMP_WORDS[@]:1:$((COMP_CWORD - 1))}") + fi local compline="${compwords[*]}" + COMPREPLY=() + if [[ -n "$COMPLETELY_DEBUG" ]]; then echo "compline: '$compline'" > 'completely-debug.txt' echo "cur: '$cur'" >> 'completely-debug.txt' diff --git a/spec/completely/installer_spec.rb b/spec/completely/installer_spec.rb index 9c78caf..f74f6fc 100644 --- a/spec/completely/installer_spec.rb +++ b/spec/completely/installer_spec.rb @@ -14,18 +14,20 @@ end describe '::from_io' do - let(:io) { StringIO.new 'dummy data' } subject { described_class.from_io program:, io: } + let(:io) { StringIO.new 'dummy data' } + it 'reads the script from io and writes it to a temp file' do expect(File.read subject.script_path).to eq 'dummy data' end end describe '::from_string' do - let(:string) { 'dummy data' } subject { described_class.from_string program:, string: } + let(:string) { 'dummy data' } + it 'reads the script from io and writes it to a temp file' do expect(File.read subject.script_path).to eq 'dummy data' end diff --git a/spec/fixtures/tester/default.bash b/spec/fixtures/tester/default.bash index 0fa0814..a5a878f 100644 --- a/spec/fixtures/tester/default.bash +++ b/spec/fixtures/tester/default.bash @@ -9,24 +9,46 @@ _cli_completions_filter() { local cur=${COMP_WORDS[COMP_CWORD]} local result=() + # words the user already typed (excluding the command itself) + local used=() + if ((COMP_CWORD > 1)); then + used=("${COMP_WORDS[@]:1:$((COMP_CWORD - 1))}") + fi + if [[ "${cur:0:1}" == "-" ]]; then + # Completing an option: offer everything (including options) echo "$words" else + # Completing a non-option: offer only non-options, + # and don't re-offer ones already used earlier in the line. for word in $words; do - [[ "${word:0:1}" != "-" ]] && result+=("$word") + [[ "${word:0:1}" == "-" ]] && continue + + local seen=0 + for u in "${used[@]}"; do + if [[ "$u" == "$word" ]]; then + seen=1 + break + fi + done + ((!seen)) && result+=("$word") done echo "${result[*]}" - fi } _cli_completions() { local cur=${COMP_WORDS[COMP_CWORD]} - local compwords=("${COMP_WORDS[@]:1:$COMP_CWORD-1}") + local compwords=() + if ((COMP_CWORD > 0)); then + compwords=("${COMP_WORDS[@]:1:$((COMP_CWORD - 1))}") + fi local compline="${compwords[*]}" + COMPREPLY=() + case "$compline" in 'command childcommand'*) while read -r; do COMPREPLY+=("$REPLY"); done < <(compgen -W "$(_cli_completions_filter "--quiet --verbose -q -v")" -- "$cur")