completely 0.8.0.rc1 → 0.8.0.rc2
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/pattern.rb +1 -5
- data/lib/completely/templates/template.erb +12 -22
- 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: 6d0582777cb78d66e4490a8f7f941de869281ab50aef1ad4cb9a6a57461fb45b
|
|
4
|
+
data.tar.gz: dafc8bdb605da6cde23bf30a8a0fdea1b989509b44dce37a83a91c64376ed3ad
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 72d2fe448ef4fd313da9ca850c1b6a71f60882d84023c724a85fff6f777b128c8e542db0c2e373a6423e65960aaec3977990ac845744244adef89b80bfd4bb23
|
|
7
|
+
data.tar.gz: '081b9173573eed04ce23afed2aa8fad0f94ab242f6975d07d15ad124afb21a1281d44bbae6ac161262177025bf8021975694699890384f8f975393c43fcd0796'
|
data/lib/completely/pattern.rb
CHANGED
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
module Completely
|
|
2
2
|
class Pattern
|
|
3
|
-
DYNAMIC_WORD_PREFIX = '__completely_dynamic__'
|
|
4
|
-
|
|
5
3
|
attr_reader :text, :completions, :function_name
|
|
6
4
|
|
|
7
5
|
def initialize(text, completions, function_name)
|
|
@@ -65,9 +63,7 @@ module Completely
|
|
|
65
63
|
end
|
|
66
64
|
|
|
67
65
|
def serialize_word(word)
|
|
68
|
-
if dynamic_word?(word)
|
|
69
|
-
return %("#{DYNAMIC_WORD_PREFIX}#{escape_for_double_quotes word}")
|
|
70
|
-
end
|
|
66
|
+
return word if dynamic_word?(word)
|
|
71
67
|
|
|
72
68
|
%("#{escape_for_double_quotes word}")
|
|
73
69
|
end
|
|
@@ -9,7 +9,6 @@
|
|
|
9
9
|
local cur=${COMP_WORDS[COMP_CWORD]}
|
|
10
10
|
local result=()
|
|
11
11
|
local want_options=0
|
|
12
|
-
local dynamic_prefix="<%= Completely::Pattern::DYNAMIC_WORD_PREFIX %>"
|
|
13
12
|
|
|
14
13
|
# words the user already typed (excluding the command itself)
|
|
15
14
|
local used=()
|
|
@@ -21,29 +20,19 @@
|
|
|
21
20
|
# Completing a non-option: drop options and already-used words.
|
|
22
21
|
[[ "${cur:0:1}" == "-" ]] && want_options=1
|
|
23
22
|
for word in "${words[@]}"; do
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
word="${word#"$dynamic_prefix"}"
|
|
27
|
-
word="${word//$'\r'/ }"
|
|
28
|
-
word="${word//$'\n'/ }"
|
|
29
|
-
read -r -a candidates <<<"$word"
|
|
30
|
-
fi
|
|
31
|
-
|
|
32
|
-
for candidate in "${candidates[@]}"; do
|
|
33
|
-
if ((!want_options)); then
|
|
34
|
-
[[ "${candidate:0:1}" == "-" ]] && continue
|
|
23
|
+
if ((!want_options)); then
|
|
24
|
+
[[ "${word:0:1}" == "-" ]] && continue
|
|
35
25
|
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
26
|
+
for u in "${used[@]}"; do
|
|
27
|
+
if [[ "$u" == "$word" ]]; then
|
|
28
|
+
continue 2
|
|
29
|
+
fi
|
|
30
|
+
done
|
|
31
|
+
fi
|
|
42
32
|
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
done
|
|
33
|
+
# compgen -W expects shell-escaped words in one space-delimited string.
|
|
34
|
+
printf -v word '%q' "$word"
|
|
35
|
+
result+=("$word")
|
|
47
36
|
done
|
|
48
37
|
|
|
49
38
|
echo "${result[*]}"
|
|
@@ -70,6 +59,7 @@
|
|
|
70
59
|
% patterns.each do |pattern|
|
|
71
60
|
% next if pattern.empty?
|
|
72
61
|
<%= pattern.case_string %>)
|
|
62
|
+
# shellcheck disable=SC2046 # intentional splitting for dynamic $(...) completions
|
|
73
63
|
while read -r; do COMPREPLY+=("$REPLY"); done < <(compgen <%= pattern.compgen %> -- "$cur")
|
|
74
64
|
;;
|
|
75
65
|
|
data/lib/completely/version.rb
CHANGED