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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c08af2e45d441174aa7ba877f55ce3ab49ed37c066abba5b522f404226c4fb09
4
- data.tar.gz: 4096cfb3dd365eece6ad5801cde77ca2127fe0500404839949d8e4b6a3c0ec85
3
+ metadata.gz: da96ad6408e1fb83fe82d923c1e81e4361e980f26e3f0877b0861d7671b4ba02
4
+ data.tar.gz: e352accd9df02816b08ace6ab3416c9a1c82b64c8dde783772c3eaab6a96a397
5
5
  SHA512:
6
- metadata.gz: b8d65f92118b3700b77803005d936a3b1ddee313936207387496d7685bd6361ffcb3fbe6c28bd8c3b5b7fb7d4d1bd1b259e1e898da1b9739df07b99e17e89c1f
7
- data.tar.gz: 398311bc0f57a4722a10d37776aad1a4e0651986a35832fc54a087618fcc3995543a21e35880deaa8ada9b88bfbc91183201c0a8bdf174ebb69ccd34e6233006
6
+ metadata.gz: 034e76f8cf366655b8b6e33a38cb1042b13fca7d9c8ec5e3ea4de3df260c49d69dbc83c27db477061261cb027adb4f080ab45c9297dff3f28b3e9a610f920f5e
7
+ data.tar.gz: ebc3b3c4a6ce2e70b56c85cc83c0235e52a0d940c88179ee22147e240cb200a2cef7c6af1bccd2d51a36c5c62d0ec592035e483d35f14e844efb949d1490cdac
@@ -137,10 +137,6 @@ module Completely
137
137
  end
138
138
  end
139
139
 
140
- def pattern_options_with_values
141
- config.model[:options].values.flatten.select { |option| option[:value] }
142
- end
143
-
144
140
  def pattern_source_empty?(source)
145
141
  source[:items].empty?
146
142
  end
@@ -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 %>_flag_expects_value() {
8
- case "$1" in
9
- % pattern_options_with_values.each do |option|
10
- <%= option[:names].map { |name| bash_escape name }.join('|') %>) return 0 ;;
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 %>_flag_expects_value "$word"; then
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
@@ -1,3 +1,3 @@
1
1
  module Completely
2
- VERSION = '0.8.0.rc3'
2
+ VERSION = '0.8.0.rc4'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: completely
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.0.rc3
4
+ version: 0.8.0.rc4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Danny Ben Shitrit