Skip to content

Commit 65cf0c6

Browse files
committed
fix shfmt violations
1 parent 26d6f19 commit 65cf0c6

File tree

3 files changed

+29
-7
lines changed

3 files changed

+29
-7
lines changed

lib/bashly/views/command/usage_options.gtx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ if flags.any? || fixed_flags?
66
options_caption = strings[:global_options]
77
end
88

9-
> printf "%s\n" "{{ options_caption.color(:caption) }}"
9+
> printf "%s\n" "{{ options_caption.color(:caption) }}"
1010
>
11-
= render(:usage_flags).indent 2 if flags.any?
12-
= render(:usage_fixed_flags).indent 2
11+
= render(:usage_flags) if flags.any?
12+
= render(:usage_fixed_flags)
1313
end

spec/fixtures/workspaces/catch-all-including-help/src/docker_command.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
show_help=${args[--show-help-anyway]-}
1+
show_help=${args["--show-help-anyway"]-}
22

33
if [[ $show_help ]]; then
44
long_usage=yes

spec/fixtures/workspaces/lib-upgrade/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\'*)'
3456
echo $' while read -r; do COMPREPLY+=("$REPLY"); done < <(compgen -W "$(_cli_completions_filter "--force --help -f -h")" -- "$cur")'

0 commit comments

Comments
 (0)