Skip to content

Commit 890f911

Browse files
authored
Merge pull request #675 from bashly-framework/upgrade/completely
Test with completely 0.7.3
2 parents a29a2fc + 7da7ab4 commit 890f911

File tree

10 files changed

+202
-26
lines changed

10 files changed

+202
-26
lines changed

examples/completions/src/lib/send_completions.sh

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,24 +11,46 @@ send_completions() {
1111
echo $' local cur=${COMP_WORDS[COMP_CWORD]}'
1212
echo $' local result=()'
1313
echo $''
14+
echo $' # words the user already typed (excluding the command itself)'
15+
echo $' local used=()'
16+
echo $' if ((COMP_CWORD > 1)); then'
17+
echo $' used=("${COMP_WORDS[@]:1:$((COMP_CWORD - 1))}")'
18+
echo $' fi'
19+
echo $''
1420
echo $' if [[ "${cur:0:1}" == "-" ]]; then'
21+
echo $' # Completing an option: offer everything (including options)'
1522
echo $' echo "$words"'
1623
echo $''
1724
echo $' else'
25+
echo $' # Completing a non-option: offer only non-options,'
26+
echo $' # and don\'t re-offer ones already used earlier in the line.'
1827
echo $' for word in $words; do'
19-
echo $' [[ "${word:0:1}" != "-" ]] && result+=("$word")'
28+
echo $' [[ "${word:0:1}" == "-" ]] && continue'
29+
echo $''
30+
echo $' local seen=0'
31+
echo $' for u in "${used[@]}"; do'
32+
echo $' if [[ "$u" == "$word" ]]; then'
33+
echo $' seen=1'
34+
echo $' break'
35+
echo $' fi'
36+
echo $' done'
37+
echo $' ((!seen)) && result+=("$word")'
2038
echo $' done'
2139
echo $''
2240
echo $' echo "${result[*]}"'
23-
echo $''
2441
echo $' fi'
2542
echo $'}'
2643
echo $''
2744
echo $'_cli_completions() {'
2845
echo $' local cur=${COMP_WORDS[COMP_CWORD]}'
29-
echo $' local compwords=("${COMP_WORDS[@]:1:$COMP_CWORD-1}")'
46+
echo $' local compwords=()'
47+
echo $' if ((COMP_CWORD > 0)); then'
48+
echo $' compwords=("${COMP_WORDS[@]:1:$((COMP_CWORD - 1))}")'
49+
echo $' fi'
3050
echo $' local compline="${compwords[*]}"'
3151
echo $''
52+
echo $' COMPREPLY=()'
53+
echo $''
3254
echo $' case "$compline" in'
3355
echo $' \'download\'*\'--handler\')'
3456
echo $' while read -r; do COMPREPLY+=("$REPLY"); done < <(compgen -W "$(_cli_completions_filter "curl wget")" -- "$cur")'

examples/render-mandoc/docs/download.1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
.\" Automatically generated by Pandoc 3.2
22
.\"
3-
.TH "download" "1" "August 2025" "Version 0.1.0" "Sample application"
3+
.TH "download" "1" "September 2025" "Version 0.1.0" "Sample application"
44
.SH NAME
55
\f[B]download\f[R] \- Sample application
66
.SH SYNOPSIS

examples/render-mandoc/docs/download.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
% download(1) Version 0.1.0 | Sample application
22
% Lana Lang
3-
% August 2025
3+
% September 2025
44

55
NAME
66
==================================================

spec/approvals/cli/add/comp-function-file

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,24 +11,46 @@ send_completions() {
1111
echo $' local cur=${COMP_WORDS[COMP_CWORD]}'
1212
echo $' local result=()'
1313
echo $''
14+
echo $' # words the user already typed (excluding the command itself)'
15+
echo $' local used=()'
16+
echo $' if ((COMP_CWORD > 1)); then'
17+
echo $' used=("${COMP_WORDS[@]:1:$((COMP_CWORD - 1))}")'
18+
echo $' fi'
19+
echo $''
1420
echo $' if [[ "${cur:0:1}" == "-" ]]; then'
21+
echo $' # Completing an option: offer everything (including options)'
1522
echo $' echo "$words"'
1623
echo $''
1724
echo $' else'
25+
echo $' # Completing a non-option: offer only non-options,'
26+
echo $' # and don\'t re-offer ones already used earlier in the line.'
1827
echo $' for word in $words; do'
19-
echo $' [[ "${word:0:1}" != "-" ]] && result+=("$word")'
28+
echo $' [[ "${word:0:1}" == "-" ]] && continue'
29+
echo $''
30+
echo $' local seen=0'
31+
echo $' for u in "${used[@]}"; do'
32+
echo $' if [[ "$u" == "$word" ]]; then'
33+
echo $' seen=1'
34+
echo $' break'
35+
echo $' fi'
36+
echo $' done'
37+
echo $' ((!seen)) && result+=("$word")'
2038
echo $' done'
2139
echo $''
2240
echo $' echo "${result[*]}"'
23-
echo $''
2441
echo $' fi'
2542
echo $'}'
2643
echo $''
2744
echo $'_cli_completions() {'
2845
echo $' local cur=${COMP_WORDS[COMP_CWORD]}'
29-
echo $' local compwords=("${COMP_WORDS[@]:1:$COMP_CWORD-1}")'
46+
echo $' local compwords=()'
47+
echo $' if ((COMP_CWORD > 0)); then'
48+
echo $' compwords=("${COMP_WORDS[@]:1:$((COMP_CWORD - 1))}")'
49+
echo $' fi'
3050
echo $' local compline="${compwords[*]}"'
3151
echo $''
52+
echo $' COMPREPLY=()'
53+
echo $''
3254
echo $' case "$compline" in'
3355
echo $' \'download\'*)'
3456
echo $' while read -r; do COMPREPLY+=("$REPLY"); done < <(compgen -W "$(_cli_completions_filter "--force --help -f -h")" -- "$cur")'

spec/approvals/cli/add/comp-script-file

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,24 +9,46 @@ _cli_completions_filter() {
99
local cur=${COMP_WORDS[COMP_CWORD]}
1010
local result=()
1111

12+
# words the user already typed (excluding the command itself)
13+
local used=()
14+
if ((COMP_CWORD > 1)); then
15+
used=("${COMP_WORDS[@]:1:$((COMP_CWORD - 1))}")
16+
fi
17+
1218
if [[ "${cur:0:1}" == "-" ]]; then
19+
# Completing an option: offer everything (including options)
1320
echo "$words"
1421

1522
else
23+
# Completing a non-option: offer only non-options,
24+
# and don't re-offer ones already used earlier in the line.
1625
for word in $words; do
17-
[[ "${word:0:1}" != "-" ]] && result+=("$word")
26+
[[ "${word:0:1}" == "-" ]] && continue
27+
28+
local seen=0
29+
for u in "${used[@]}"; do
30+
if [[ "$u" == "$word" ]]; then
31+
seen=1
32+
break
33+
fi
34+
done
35+
((!seen)) && result+=("$word")
1836
done
1937

2038
echo "${result[*]}"
21-
2239
fi
2340
}
2441

2542
_cli_completions() {
2643
local cur=${COMP_WORDS[COMP_CWORD]}
27-
local compwords=("${COMP_WORDS[@]:1:$COMP_CWORD-1}")
44+
local compwords=()
45+
if ((COMP_CWORD > 0)); then
46+
compwords=("${COMP_WORDS[@]:1:$((COMP_CWORD - 1))}")
47+
fi
2848
local compline="${compwords[*]}"
2949

50+
COMPREPLY=()
51+
3052
case "$compline" in
3153
'download'*)
3254
while read -r; do COMPREPLY+=("$REPLY"); done < <(compgen -W "$(_cli_completions_filter "--force --help -f -h")" -- "$cur")

spec/approvals/completions/function

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,24 +10,46 @@ custom_name() {
1010
echo $' local cur=${COMP_WORDS[COMP_CWORD]}'
1111
echo $' local result=()'
1212
echo $''
13+
echo $' # words the user already typed (excluding the command itself)'
14+
echo $' local used=()'
15+
echo $' if ((COMP_CWORD > 1)); then'
16+
echo $' used=("${COMP_WORDS[@]:1:$((COMP_CWORD - 1))}")'
17+
echo $' fi'
18+
echo $''
1319
echo $' if [[ "${cur:0:1}" == "-" ]]; then'
20+
echo $' # Completing an option: offer everything (including options)'
1421
echo $' echo "$words"'
1522
echo $''
1623
echo $' else'
24+
echo $' # Completing a non-option: offer only non-options,'
25+
echo $' # and don\'t re-offer ones already used earlier in the line.'
1726
echo $' for word in $words; do'
18-
echo $' [[ "${word:0:1}" != "-" ]] && result+=("$word")'
27+
echo $' [[ "${word:0:1}" == "-" ]] && continue'
28+
echo $''
29+
echo $' local seen=0'
30+
echo $' for u in "${used[@]}"; do'
31+
echo $' if [[ "$u" == "$word" ]]; then'
32+
echo $' seen=1'
33+
echo $' break'
34+
echo $' fi'
35+
echo $' done'
36+
echo $' ((!seen)) && result+=("$word")'
1937
echo $' done'
2038
echo $''
2139
echo $' echo "${result[*]}"'
22-
echo $''
2340
echo $' fi'
2441
echo $'}'
2542
echo $''
2643
echo $'_get_completions() {'
2744
echo $' local cur=${COMP_WORDS[COMP_CWORD]}'
28-
echo $' local compwords=("${COMP_WORDS[@]:1:$COMP_CWORD-1}")'
45+
echo $' local compwords=()'
46+
echo $' if ((COMP_CWORD > 0)); then'
47+
echo $' compwords=("${COMP_WORDS[@]:1:$((COMP_CWORD - 1))}")'
48+
echo $' fi'
2949
echo $' local compline="${compwords[*]}"'
3050
echo $''
51+
echo $' COMPREPLY=()'
52+
echo $''
3153
echo $' case "$compline" in'
3254
echo $' *)'
3355
echo $' while read -r; do COMPREPLY+=("$REPLY"); done < <(compgen -A file -W "$(_get_completions_filter "--force --help --verbose --version -h -v")" -- "$cur")'

spec/approvals/completions/script

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,24 +9,46 @@ _say_completions_filter() {
99
local cur=${COMP_WORDS[COMP_CWORD]}
1010
local result=()
1111

12+
# words the user already typed (excluding the command itself)
13+
local used=()
14+
if ((COMP_CWORD > 1)); then
15+
used=("${COMP_WORDS[@]:1:$((COMP_CWORD - 1))}")
16+
fi
17+
1218
if [[ "${cur:0:1}" == "-" ]]; then
19+
# Completing an option: offer everything (including options)
1320
echo "$words"
1421

1522
else
23+
# Completing a non-option: offer only non-options,
24+
# and don't re-offer ones already used earlier in the line.
1625
for word in $words; do
17-
[[ "${word:0:1}" != "-" ]] && result+=("$word")
26+
[[ "${word:0:1}" == "-" ]] && continue
27+
28+
local seen=0
29+
for u in "${used[@]}"; do
30+
if [[ "$u" == "$word" ]]; then
31+
seen=1
32+
break
33+
fi
34+
done
35+
((!seen)) && result+=("$word")
1836
done
1937

2038
echo "${result[*]}"
21-
2239
fi
2340
}
2441

2542
_say_completions() {
2643
local cur=${COMP_WORDS[COMP_CWORD]}
27-
local compwords=("${COMP_WORDS[@]:1:$COMP_CWORD-1}")
44+
local compwords=()
45+
if ((COMP_CWORD > 0)); then
46+
compwords=("${COMP_WORDS[@]:1:$((COMP_CWORD - 1))}")
47+
fi
2848
local compline="${compwords[*]}"
2949

50+
COMPREPLY=()
51+
3052
case "$compline" in
3153
'goodbye universe'*'--color')
3254
while read -r; do COMPREPLY+=("$REPLY"); done < <(compgen -W "$(_say_completions_filter "green red")" -- "$cur")

spec/approvals/examples/completions

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -73,24 +73,46 @@ _cli_completions_filter() {
7373
local cur=${COMP_WORDS[COMP_CWORD]}
7474
local result=()
7575

76+
# words the user already typed (excluding the command itself)
77+
local used=()
78+
if ((COMP_CWORD > 1)); then
79+
used=("${COMP_WORDS[@]:1:$((COMP_CWORD - 1))}")
80+
fi
81+
7682
if [[ "${cur:0:1}" == "-" ]]; then
83+
# Completing an option: offer everything (including options)
7784
echo "$words"
7885

7986
else
87+
# Completing a non-option: offer only non-options,
88+
# and don't re-offer ones already used earlier in the line.
8089
for word in $words; do
81-
[[ "${word:0:1}" != "-" ]] && result+=("$word")
90+
[[ "${word:0:1}" == "-" ]] && continue
91+
92+
local seen=0
93+
for u in "${used[@]}"; do
94+
if [[ "$u" == "$word" ]]; then
95+
seen=1
96+
break
97+
fi
98+
done
99+
((!seen)) && result+=("$word")
82100
done
83101

84102
echo "${result[*]}"
85-
86103
fi
87104
}
88105

89106
_cli_completions() {
90107
local cur=${COMP_WORDS[COMP_CWORD]}
91-
local compwords=("${COMP_WORDS[@]:1:$COMP_CWORD-1}")
108+
local compwords=()
109+
if ((COMP_CWORD > 0)); then
110+
compwords=("${COMP_WORDS[@]:1:$((COMP_CWORD - 1))}")
111+
fi
92112
local compline="${compwords[*]}"
93113

114+
COMPREPLY=()
115+
94116
case "$compline" in
95117
'download'*'--handler')
96118
while read -r; do COMPREPLY+=("$REPLY"); done < <(compgen -W "$(_cli_completions_filter "curl wget")" -- "$cur")

spec/approvals/libraries/completions_function/files

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,24 +14,46 @@
1414
echo $' local cur=${COMP_WORDS[COMP_CWORD]}'
1515
echo $' local result=()'
1616
echo $''
17+
echo $' # words the user already typed (excluding the command itself)'
18+
echo $' local used=()'
19+
echo $' if ((COMP_CWORD > 1)); then'
20+
echo $' used=("${COMP_WORDS[@]:1:$((COMP_CWORD - 1))}")'
21+
echo $' fi'
22+
echo $''
1723
echo $' if [[ "${cur:0:1}" == "-" ]]; then'
24+
echo $' # Completing an option: offer everything (including options)'
1825
echo $' echo "$words"'
1926
echo $''
2027
echo $' else'
28+
echo $' # Completing a non-option: offer only non-options,'
29+
echo $' # and don\'t re-offer ones already used earlier in the line.'
2130
echo $' for word in $words; do'
22-
echo $' [[ "${word:0:1}" != "-" ]] && result+=("$word")'
31+
echo $' [[ "${word:0:1}" == "-" ]] && continue'
32+
echo $''
33+
echo $' local seen=0'
34+
echo $' for u in "${used[@]}"; do'
35+
echo $' if [[ "$u" == "$word" ]]; then'
36+
echo $' seen=1'
37+
echo $' break'
38+
echo $' fi'
39+
echo $' done'
40+
echo $' ((!seen)) && result+=("$word")'
2341
echo $' done'
2442
echo $''
2543
echo $' echo "${result[*]}"'
26-
echo $''
2744
echo $' fi'
2845
echo $'}'
2946
echo $''
3047
echo $'_download_completions() {'
3148
echo $' local cur=${COMP_WORDS[COMP_CWORD]}'
32-
echo $' local compwords=("${COMP_WORDS[@]:1:$COMP_CWORD-1}")'
49+
echo $' local compwords=()'
50+
echo $' if ((COMP_CWORD > 0)); then'
51+
echo $' compwords=("${COMP_WORDS[@]:1:$((COMP_CWORD - 1))}")'
52+
echo $' fi'
3353
echo $' local compline="${compwords[*]}"'
3454
echo $''
55+
echo $' COMPREPLY=()'
56+
echo $''
3557
echo $' case "$compline" in'
3658
echo $' *)'
3759
echo $' while read -r; do COMPREPLY+=("$REPLY"); done < <(compgen -W "$(_download_completions_filter "--force --help --version -f -h -v")" -- "$cur")'

0 commit comments

Comments
 (0)