completely 0.7.3 → 0.7.4
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/README.md +2 -0
- data/lib/completely/commands/generate.rb +1 -1
- data/lib/completely/installer.rb +17 -30
- data/lib/completely/pattern.rb +9 -1
- data/lib/completely/templates/template.erb +15 -16
- data/lib/completely/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: e03a96457b69bced5091cb3a335f60da59ed7629d836f985f6bef54e89f8d827
|
|
4
|
+
data.tar.gz: fb9fdf6333328841bb45fd65a6428571934602f13d5c7f1b555bc6dc7120c224
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: b085523a2bb092c928fd6ff908baef5e5e1c0c68775688ea5e1a31ba77e19c09acfd17c19395f513a44eae88c9ab36cb28784e6ddae1afda46053d8de3f79981
|
|
7
|
+
data.tar.gz: '0835d18cf9bf62f98c794368d39173263890856fe15ee601455b272ac5944a311a7bfee3e9eb6b8aa9ea215c2cd4713b7b5eb5e9c2c8cfb89764149064b41273'
|
data/README.md
CHANGED
data/lib/completely/installer.rb
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
require 'fileutils'
|
|
2
|
+
|
|
1
3
|
module Completely
|
|
2
4
|
class Installer
|
|
3
5
|
class << self
|
|
@@ -38,18 +40,8 @@ module Completely
|
|
|
38
40
|
@script_path = script_path
|
|
39
41
|
end
|
|
40
42
|
|
|
41
|
-
def target_directories
|
|
42
|
-
@target_directories ||= %W[
|
|
43
|
-
/usr/share/bash-completion/completions
|
|
44
|
-
/usr/local/etc/bash_completion.d
|
|
45
|
-
#{Dir.home}/.local/share/bash-completion/completions
|
|
46
|
-
#{Dir.home}/.bash_completion.d
|
|
47
|
-
]
|
|
48
|
-
end
|
|
49
|
-
|
|
50
43
|
def install_command
|
|
51
|
-
|
|
52
|
-
result + %W[cp #{script_path} #{target_path}]
|
|
44
|
+
%W[cp #{script_path} #{target_path}]
|
|
53
45
|
end
|
|
54
46
|
|
|
55
47
|
def install_command_string
|
|
@@ -57,8 +49,7 @@ module Completely
|
|
|
57
49
|
end
|
|
58
50
|
|
|
59
51
|
def uninstall_command
|
|
60
|
-
|
|
61
|
-
result + %w[rm -f] + target_directories.map { |dir| "#{dir}/#{program}" }
|
|
52
|
+
%W[rm -f #{target_path}]
|
|
62
53
|
end
|
|
63
54
|
|
|
64
55
|
def uninstall_command_string
|
|
@@ -70,14 +61,12 @@ module Completely
|
|
|
70
61
|
end
|
|
71
62
|
|
|
72
63
|
def install(force: false)
|
|
73
|
-
unless completions_path
|
|
74
|
-
raise InstallError, 'Cannot determine system completions directory'
|
|
75
|
-
end
|
|
76
|
-
|
|
77
64
|
unless script_exist?
|
|
78
65
|
raise InstallError, "Cannot find script: m`#{script_path}`"
|
|
79
66
|
end
|
|
80
67
|
|
|
68
|
+
FileUtils.mkdir_p completions_path
|
|
69
|
+
|
|
81
70
|
if target_exist? && !force
|
|
82
71
|
raise InstallError, "File exists: m`#{target_path}`"
|
|
83
72
|
end
|
|
@@ -99,22 +88,20 @@ module Completely
|
|
|
99
88
|
File.exist? script_path
|
|
100
89
|
end
|
|
101
90
|
|
|
102
|
-
def
|
|
103
|
-
|
|
91
|
+
def completions_path
|
|
92
|
+
@completions_path ||= "#{user_completions_base_dir}/completions"
|
|
104
93
|
end
|
|
105
94
|
|
|
106
|
-
def
|
|
107
|
-
@
|
|
108
|
-
|
|
109
|
-
target_directories.each do |target|
|
|
110
|
-
if Dir.exist? target
|
|
111
|
-
result = target
|
|
112
|
-
break
|
|
113
|
-
end
|
|
114
|
-
end
|
|
95
|
+
def user_completions_base_dir
|
|
96
|
+
@user_completions_base_dir ||= bash_completion_user_dir || "#{data_home}/bash-completion"
|
|
97
|
+
end
|
|
115
98
|
|
|
116
|
-
|
|
117
|
-
|
|
99
|
+
def bash_completion_user_dir
|
|
100
|
+
ENV['BASH_COMPLETION_USER_DIR']&.split(':')&.find { |entry| !entry.empty? }
|
|
101
|
+
end
|
|
102
|
+
|
|
103
|
+
def data_home
|
|
104
|
+
ENV['XDG_DATA_HOME'] || "#{Dir.home}/.local/share"
|
|
118
105
|
end
|
|
119
106
|
end
|
|
120
107
|
end
|
data/lib/completely/pattern.rb
CHANGED
|
@@ -54,8 +54,16 @@ module Completely
|
|
|
54
54
|
def compgen!
|
|
55
55
|
result = []
|
|
56
56
|
result << actions.join(' ').to_s if actions.any?
|
|
57
|
-
result << %[-W "$(#{function_name}
|
|
57
|
+
result << %[-W "$(#{function_name} #{quoted_words.join ' '})"] if words.any?
|
|
58
58
|
result.any? ? result.join(' ') : nil
|
|
59
59
|
end
|
|
60
|
+
|
|
61
|
+
def quoted_words
|
|
62
|
+
@quoted_words ||= words.map { |word| %("#{escape_for_double_quotes word}") }
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
def escape_for_double_quotes(word)
|
|
66
|
+
word.gsub(/["\\]/, '\\\\\&')
|
|
67
|
+
end
|
|
60
68
|
end
|
|
61
69
|
end
|
|
@@ -5,9 +5,10 @@
|
|
|
5
5
|
# Modifying it manually is not recommended
|
|
6
6
|
|
|
7
7
|
<%= function_name %>_filter() {
|
|
8
|
-
local words="
|
|
8
|
+
local words=("$@")
|
|
9
9
|
local cur=${COMP_WORDS[COMP_CWORD]}
|
|
10
10
|
local result=()
|
|
11
|
+
local want_options=0
|
|
11
12
|
|
|
12
13
|
# words the user already typed (excluding the command itself)
|
|
13
14
|
local used=()
|
|
@@ -15,28 +16,26 @@
|
|
|
15
16
|
used=("${COMP_WORDS[@]:1:$((COMP_CWORD - 1))}")
|
|
16
17
|
fi
|
|
17
18
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
# Completing a non-option: offer only non-options,
|
|
24
|
-
# and don't re-offer ones already used earlier in the line.
|
|
25
|
-
for word in $words; do
|
|
19
|
+
# Completing an option: offer everything.
|
|
20
|
+
# Completing a non-option: drop options and already-used words.
|
|
21
|
+
[[ "${cur:0:1}" == "-" ]] && want_options=1
|
|
22
|
+
for word in "${words[@]}"; do
|
|
23
|
+
if ((!want_options)); then
|
|
26
24
|
[[ "${word:0:1}" == "-" ]] && continue
|
|
27
25
|
|
|
28
|
-
local seen=0
|
|
29
26
|
for u in "${used[@]}"; do
|
|
30
27
|
if [[ "$u" == "$word" ]]; then
|
|
31
|
-
|
|
32
|
-
break
|
|
28
|
+
continue 2
|
|
33
29
|
fi
|
|
34
30
|
done
|
|
35
|
-
|
|
36
|
-
done
|
|
31
|
+
fi
|
|
37
32
|
|
|
38
|
-
|
|
39
|
-
|
|
33
|
+
# compgen -W expects shell-escaped words in one space-delimited string.
|
|
34
|
+
printf -v word '%q' "$word"
|
|
35
|
+
result+=("$word")
|
|
36
|
+
done
|
|
37
|
+
|
|
38
|
+
echo "${result[*]}"
|
|
40
39
|
}
|
|
41
40
|
|
|
42
41
|
<%= function_name %>() {
|
data/lib/completely/version.rb
CHANGED
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.7.
|
|
4
|
+
version: 0.7.4
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Danny Ben Shitrit
|
|
@@ -88,7 +88,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
88
88
|
- !ruby/object:Gem::Version
|
|
89
89
|
version: '0'
|
|
90
90
|
requirements: []
|
|
91
|
-
rubygems_version:
|
|
91
|
+
rubygems_version: 4.0.6
|
|
92
92
|
specification_version: 4
|
|
93
93
|
summary: Bash Completions Generator
|
|
94
94
|
test_files: []
|