completely 0.8.0.rc3 → 0.8.0.rc4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/completely/completions.rb +0 -4
- data/lib/completely/templates/pattern-config/template.erb +36 -24
- data/lib/completely/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: da96ad6408e1fb83fe82d923c1e81e4361e980f26e3f0877b0861d7671b4ba02
|
|
4
|
+
data.tar.gz: e352accd9df02816b08ace6ab3416c9a1c82b64c8dde783772c3eaab6a96a397
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 034e76f8cf366655b8b6e33a38cb1042b13fca7d9c8ec5e3ea4de3df260c49d69dbc83c27db477061261cb027adb4f080ab45c9297dff3f28b3e9a610f920f5e
|
|
7
|
+
data.tar.gz: ebc3b3c4a6ce2e70b56c85cc83c0235e52a0d940c88179ee22147e240cb200a2cef7c6af1bccd2d51a36c5c62d0ec592035e483d35f14e844efb949d1490cdac
|
|
@@ -4,16 +4,40 @@
|
|
|
4
4
|
# completely (https://github.com/bashly-framework/completely)
|
|
5
5
|
# Modifying it manually is not recommended
|
|
6
6
|
|
|
7
|
-
<%= function_name %>
|
|
8
|
-
case "$1" in
|
|
9
|
-
%
|
|
10
|
-
|
|
7
|
+
<%= function_name %>_route_flag_expects_value() {
|
|
8
|
+
case "$1:$2" in
|
|
9
|
+
% pattern_routes.each do |route|
|
|
10
|
+
% pattern_route_options(route).select { |option| option[:value] }.each do |option|
|
|
11
|
+
<%= pattern_route_id route %>:<%= option[:names].map { |name| bash_escape name }.join("|#{pattern_route_id route}:") %>) return 0 ;;
|
|
12
|
+
% end
|
|
11
13
|
% end
|
|
12
14
|
esac
|
|
13
15
|
|
|
14
16
|
return 1
|
|
15
17
|
}
|
|
16
18
|
|
|
19
|
+
<%= function_name %>_resolve_route() {
|
|
20
|
+
route_id=
|
|
21
|
+
route_word_count=-1
|
|
22
|
+
route_has_positionals=0
|
|
23
|
+
positional_index=0
|
|
24
|
+
% pattern_routes.each do |route|
|
|
25
|
+
% conditions = pattern_route_conditions(route)
|
|
26
|
+
if (( ${#non_options[@]} >= <%= pattern_route_word_count route %> )) &&
|
|
27
|
+
(( <%= pattern_route_word_count route %> > route_word_count ))<%= conditions.empty? ? '' : ' &&' %>
|
|
28
|
+
% conditions.each_with_index do |condition, index|
|
|
29
|
+
[[ <%= condition %> ]]<%= index == conditions.size - 1 ? '' : ' &&' %>
|
|
30
|
+
% end
|
|
31
|
+
then
|
|
32
|
+
route_id=<%= pattern_route_id route %>
|
|
33
|
+
route_word_count=<%= pattern_route_word_count route %>
|
|
34
|
+
route_has_positionals=<%= route[:positionals].empty? ? 0 : 1 %>
|
|
35
|
+
positional_index=$((${#non_options[@]} - <%= pattern_route_word_count route %>))
|
|
36
|
+
fi
|
|
37
|
+
|
|
38
|
+
% end
|
|
39
|
+
}
|
|
40
|
+
|
|
17
41
|
<%= function_name %>() {
|
|
18
42
|
local cur=${COMP_WORDS[COMP_CWORD]}
|
|
19
43
|
local prev=
|
|
@@ -28,6 +52,12 @@
|
|
|
28
52
|
|
|
29
53
|
local non_options=()
|
|
30
54
|
local completed_options=()
|
|
55
|
+
local route_id=
|
|
56
|
+
local route_word_count=-1
|
|
57
|
+
local route_has_positionals=0
|
|
58
|
+
local positional_index=0
|
|
59
|
+
<%= function_name %>_resolve_route
|
|
60
|
+
|
|
31
61
|
local skip_next=0
|
|
32
62
|
for word in "${completed[@]}"; do
|
|
33
63
|
if ((skip_next)); then
|
|
@@ -37,34 +67,16 @@
|
|
|
37
67
|
|
|
38
68
|
if [[ "${word:0:1}" == "-" ]]; then
|
|
39
69
|
completed_options+=("$word")
|
|
40
|
-
if <%= function_name %>
|
|
70
|
+
if <%= function_name %>_route_flag_expects_value "$route_id" "$word"; then
|
|
41
71
|
skip_next=1
|
|
42
72
|
fi
|
|
43
73
|
continue
|
|
44
74
|
fi
|
|
45
75
|
|
|
46
76
|
non_options+=("$word")
|
|
77
|
+
<%= function_name %>_resolve_route
|
|
47
78
|
done
|
|
48
79
|
|
|
49
|
-
local route_id=
|
|
50
|
-
local route_word_count=-1
|
|
51
|
-
local route_has_positionals=0
|
|
52
|
-
local positional_index=0
|
|
53
|
-
% pattern_routes.each do |route|
|
|
54
|
-
% conditions = pattern_route_conditions(route)
|
|
55
|
-
if (( ${#non_options[@]} >= <%= pattern_route_word_count route %> )) &&
|
|
56
|
-
(( <%= pattern_route_word_count route %> > route_word_count ))<%= conditions.empty? ? '' : ' &&' %>
|
|
57
|
-
% conditions.each_with_index do |condition, index|
|
|
58
|
-
[[ <%= condition %> ]]<%= index == conditions.size - 1 ? '' : ' &&' %>
|
|
59
|
-
% end
|
|
60
|
-
then
|
|
61
|
-
route_id=<%= pattern_route_id route %>
|
|
62
|
-
route_word_count=<%= pattern_route_word_count route %>
|
|
63
|
-
route_has_positionals=<%= route[:positionals].empty? ? 0 : 1 %>
|
|
64
|
-
positional_index=$((${#non_options[@]} - <%= pattern_route_word_count route %>))
|
|
65
|
-
fi
|
|
66
|
-
|
|
67
|
-
% end
|
|
68
80
|
COMPREPLY=()
|
|
69
81
|
|
|
70
82
|
if [[ -z "$route_id" ]] || { (( route_word_count == 0 )) && (( !route_has_positionals )) && [[ "${cur:0:1}" != "-" ]]; }; then
|
data/lib/completely/version.rb
CHANGED