Skip to content

Commit 763b1d8

Browse files
committed
update completely to 0.8.0.rc4
1 parent 6cd2c04 commit 763b1d8

2 files changed

Lines changed: 53 additions & 43 deletions

File tree

bashly.gemspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ Gem::Specification.new do |s|
1616
s.required_ruby_version = '>= 3.2'
1717

1818
s.add_dependency 'colsole', '~> 1.0'
19-
s.add_dependency 'completely', '~> 0.8.0.rc3'
19+
s.add_dependency 'completely', '~> 0.8.0.rc4'
2020
s.add_dependency 'gtx', '~> 0.1.1'
2121
s.add_dependency 'listen', '~> 3.9'
2222
s.add_dependency 'lp', '~> 0.2.0'

lib/bashly/completions/bashly-completions.bash

Lines changed: 52 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -4,53 +4,22 @@
44
# completely (https://github.com/bashly-framework/completely)
55
# Modifying it manually is not recommended
66

7-
_bashly_completions_flag_expects_value() {
8-
case "$1" in
9-
--env|-e) return 0 ;;
10-
--wrap|-r) return 0 ;;
11-
--source|-s) return 0 ;;
12-
--show|-s) return 0 ;;
7+
_bashly_completions_route_flag_expects_value() {
8+
case "$1:$2" in
9+
4:--env|4:-e) return 0 ;;
10+
4:--wrap|4:-r) return 0 ;;
11+
5:--source|5:-s) return 0 ;;
12+
8:--show|8:-s) return 0 ;;
1313
esac
1414

1515
return 1
1616
}
1717

18-
_bashly_completions() {
19-
local cur=${COMP_WORDS[COMP_CWORD]}
20-
local prev=
21-
if ((COMP_CWORD > 0)); then
22-
prev=${COMP_WORDS[$((COMP_CWORD - 1))]}
23-
fi
24-
25-
local completed=()
26-
if ((COMP_CWORD > 1)); then
27-
completed=("${COMP_WORDS[@]:1:$((COMP_CWORD - 1))}")
28-
fi
29-
30-
local non_options=()
31-
local completed_options=()
32-
local skip_next=0
33-
for word in "${completed[@]}"; do
34-
if ((skip_next)); then
35-
skip_next=0
36-
continue
37-
fi
38-
39-
if [[ "${word:0:1}" == "-" ]]; then
40-
completed_options+=("$word")
41-
if _bashly_completions_flag_expects_value "$word"; then
42-
skip_next=1
43-
fi
44-
continue
45-
fi
46-
47-
non_options+=("$word")
48-
done
49-
50-
local route_id=
51-
local route_word_count=-1
52-
local route_has_positionals=0
53-
local positional_index=0
18+
_bashly_completions_resolve_route() {
19+
route_id=
20+
route_word_count=-1
21+
route_has_positionals=0
22+
positional_index=0
5423
if (( ${#non_options[@]} >= 0 )) &&
5524
(( 0 > route_word_count ))
5625
then
@@ -150,6 +119,47 @@ _bashly_completions() {
150119
positional_index=$((${#non_options[@]} - 1))
151120
fi
152121

122+
}
123+
124+
_bashly_completions() {
125+
local cur=${COMP_WORDS[COMP_CWORD]}
126+
local prev=
127+
if ((COMP_CWORD > 0)); then
128+
prev=${COMP_WORDS[$((COMP_CWORD - 1))]}
129+
fi
130+
131+
local completed=()
132+
if ((COMP_CWORD > 1)); then
133+
completed=("${COMP_WORDS[@]:1:$((COMP_CWORD - 1))}")
134+
fi
135+
136+
local non_options=()
137+
local completed_options=()
138+
local route_id=
139+
local route_word_count=-1
140+
local route_has_positionals=0
141+
local positional_index=0
142+
_bashly_completions_resolve_route
143+
144+
local skip_next=0
145+
for word in "${completed[@]}"; do
146+
if ((skip_next)); then
147+
skip_next=0
148+
continue
149+
fi
150+
151+
if [[ "${word:0:1}" == "-" ]]; then
152+
completed_options+=("$word")
153+
if _bashly_completions_route_flag_expects_value "$route_id" "$word"; then
154+
skip_next=1
155+
fi
156+
continue
157+
fi
158+
159+
non_options+=("$word")
160+
_bashly_completions_resolve_route
161+
done
162+
153163
COMPREPLY=()
154164

155165
if [[ -z "$route_id" ]] || { (( route_word_count == 0 )) && (( !route_has_positionals )) && [[ "${cur:0:1}" != "-" ]]; }; then

0 commit comments

Comments
 (0)