completely 0.5.4 → 0.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +10 -4
- data/lib/completely/commands/init.rb +1 -1
- data/lib/completely/commands/install.rb +7 -57
- data/lib/completely/exceptions.rb +4 -0
- data/lib/completely/installer.rb +73 -0
- data/lib/completely/templates/template.erb +1 -1
- data/lib/completely/version.rb +1 -1
- data/lib/completely.rb +2 -0
- metadata +10 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b40f2059243b2820d2ce140394be5551e5ddb131351adb35d26343841f8a54c7
|
4
|
+
data.tar.gz: 71e01f5c44395f97023afff5a1822c5fa651efb98155a3b8dd05f750a19a5419
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 71d90d706eb26933817483395670eb5d5ed516b606b62c1f4b9408afdec92b977142e4b2501ff12b75bb47fa971e558696ef5294a3c569f3856da8cb9904254f
|
7
|
+
data.tar.gz: df1e950e2f839a977181521bb09fb917e6d47046f4f6b80d7a8dfc557b2c5d67ee66f962b7a23fd2456137a283bae6ffc9fe38e9ad97355c53c82a1ec84cff7a
|
data/README.md
CHANGED
@@ -109,7 +109,7 @@ $ completely generate
|
|
109
109
|
$ completely preview
|
110
110
|
```
|
111
111
|
|
112
|
-
For more options (like setting input/output path), run
|
112
|
+
For more options (like setting input/output path), run:
|
113
113
|
|
114
114
|
```bash
|
115
115
|
$ completely --help
|
@@ -215,9 +215,15 @@ In order to enable the completions, simply source the generated script:
|
|
215
215
|
$ source completely.bash
|
216
216
|
```
|
217
217
|
|
218
|
-
|
219
|
-
|
220
|
-
|
218
|
+
If you are satisfied with the result, and wish to copy the script to your bash
|
219
|
+
completions directory, simply run:
|
220
|
+
|
221
|
+
```bash
|
222
|
+
$ completely install
|
223
|
+
```
|
224
|
+
|
225
|
+
Alternatively, you can copy the script manually to one of these directories
|
226
|
+
(whichever exists):
|
221
227
|
|
222
228
|
- `/usr/share/bash-completion/completions`
|
223
229
|
- `/usr/local/etc/bash_completion.d`
|
@@ -12,7 +12,7 @@ module Completely
|
|
12
12
|
environment_config_path
|
13
13
|
|
14
14
|
def run
|
15
|
-
raise "File already exists: #{config_path}" if File.exist? config_path
|
15
|
+
raise Error, "File already exists: #{config_path}" if File.exist? config_path
|
16
16
|
|
17
17
|
File.write config_path, sample
|
18
18
|
say "Saved m`#{config_path}`"
|
@@ -3,19 +3,10 @@ require 'completely/commands/base'
|
|
3
3
|
module Completely
|
4
4
|
module Commands
|
5
5
|
class Install < Base
|
6
|
-
TARGETS = %W[
|
7
|
-
/usr/share/bash-completion/completions
|
8
|
-
/usr/local/etc/bash_completion.d
|
9
|
-
#{Dir.home}/.bash_completion.d
|
10
|
-
]
|
11
|
-
|
12
6
|
summary 'Install a bash completion script'
|
13
7
|
|
14
8
|
help <<~HELP
|
15
|
-
This command will copy the specified file to one of the
|
16
|
-
|
17
|
-
#{TARGETS.map { |c| " - #{c}" }.join "\n"}
|
18
|
-
|
9
|
+
This command will copy the specified file to one of the bash completion directories.
|
19
10
|
The target filename will be the program name, and sudo will be used if necessary.
|
20
11
|
HELP
|
21
12
|
|
@@ -29,68 +20,27 @@ module Completely
|
|
29
20
|
param 'SCRIPT_PATH', 'Path to the source bash script [default: completely.bash].'
|
30
21
|
|
31
22
|
def run
|
32
|
-
bounce
|
33
|
-
|
34
23
|
if args['--dry']
|
35
|
-
puts
|
24
|
+
puts installer.command_string
|
36
25
|
return
|
37
26
|
end
|
38
27
|
|
39
|
-
success =
|
40
|
-
raise "Failed running command:\nnb`#{
|
28
|
+
success = installer.install force: args['--force']
|
29
|
+
raise InstallError, "Failed running command:\nnb`#{installer.command_string}`" unless success
|
41
30
|
|
42
|
-
say "Saved m`#{target_path}`"
|
31
|
+
say "Saved m`#{installer.target_path}`"
|
43
32
|
say 'You may need to restart your session to test it'
|
44
33
|
end
|
45
34
|
|
46
35
|
private
|
47
36
|
|
48
|
-
def
|
49
|
-
|
50
|
-
raise 'Cannot determine system completions directory'
|
51
|
-
end
|
52
|
-
|
53
|
-
unless File.exist? script_path
|
54
|
-
raise "Cannot find script: m`#{script_path}`"
|
55
|
-
end
|
56
|
-
|
57
|
-
if target_exist? && !args['--force']
|
58
|
-
raise "File exists: m`#{target_path}`\nUse nb`--force` to overwrite"
|
59
|
-
end
|
60
|
-
end
|
61
|
-
|
62
|
-
def target_exist?
|
63
|
-
File.exist? target_path
|
64
|
-
end
|
65
|
-
|
66
|
-
def command
|
67
|
-
result = root? ? [] : %w[sudo]
|
68
|
-
result + %W[cp #{script_path} #{target_path}]
|
37
|
+
def installer
|
38
|
+
Installer.new program: args['PROGRAM'], script_path: script_path
|
69
39
|
end
|
70
40
|
|
71
41
|
def script_path
|
72
42
|
args['SCRIPT_PATH'] || 'completely.bash'
|
73
43
|
end
|
74
|
-
|
75
|
-
def target_path
|
76
|
-
"#{completions_path}/#{args['PROGRAM']}"
|
77
|
-
end
|
78
|
-
|
79
|
-
def root?
|
80
|
-
Process.uid.zero?
|
81
|
-
end
|
82
|
-
|
83
|
-
def completions_path
|
84
|
-
@completions_path ||= completions_path!
|
85
|
-
end
|
86
|
-
|
87
|
-
def completions_path!
|
88
|
-
TARGETS.each do |tarnet|
|
89
|
-
return tarnet if Dir.exist? tarnet
|
90
|
-
end
|
91
|
-
|
92
|
-
nil
|
93
|
-
end
|
94
44
|
end
|
95
45
|
end
|
96
46
|
end
|
@@ -0,0 +1,73 @@
|
|
1
|
+
module Completely
|
2
|
+
class Installer
|
3
|
+
attr_reader :program, :script_path
|
4
|
+
|
5
|
+
def initialize(program:, script_path: nil)
|
6
|
+
@program = program
|
7
|
+
@script_path = script_path
|
8
|
+
end
|
9
|
+
|
10
|
+
def target_directories
|
11
|
+
@target_directories ||= %W[
|
12
|
+
/usr/share/bash-completion/completions
|
13
|
+
/usr/local/etc/bash_completion.d
|
14
|
+
#{Dir.home}/.bash_completion.d
|
15
|
+
]
|
16
|
+
end
|
17
|
+
|
18
|
+
def command
|
19
|
+
result = root_user? ? [] : %w[sudo]
|
20
|
+
result + %W[cp #{script_path} #{target_path}]
|
21
|
+
end
|
22
|
+
|
23
|
+
def command_string
|
24
|
+
command.join ' '
|
25
|
+
end
|
26
|
+
|
27
|
+
def target_path
|
28
|
+
"#{completions_path}/#{program}"
|
29
|
+
end
|
30
|
+
|
31
|
+
def install(force: false)
|
32
|
+
unless completions_path
|
33
|
+
raise InstallError, 'Cannot determine system completions directory'
|
34
|
+
end
|
35
|
+
|
36
|
+
unless script_exist?
|
37
|
+
raise InstallError, "Cannot find script: m`#{script_path}`"
|
38
|
+
end
|
39
|
+
|
40
|
+
if target_exist? && !force
|
41
|
+
raise InstallError, "File exists: m`#{target_path}`"
|
42
|
+
end
|
43
|
+
|
44
|
+
system(*command)
|
45
|
+
end
|
46
|
+
|
47
|
+
private
|
48
|
+
|
49
|
+
def target_exist?
|
50
|
+
File.exist? target_path
|
51
|
+
end
|
52
|
+
|
53
|
+
def script_exist?
|
54
|
+
File.exist? script_path
|
55
|
+
end
|
56
|
+
|
57
|
+
def root_user?
|
58
|
+
Process.uid.zero?
|
59
|
+
end
|
60
|
+
|
61
|
+
def completions_path
|
62
|
+
@completions_path ||= completions_path!
|
63
|
+
end
|
64
|
+
|
65
|
+
def completions_path!
|
66
|
+
target_directories.each do |target|
|
67
|
+
return target if Dir.exist? target
|
68
|
+
end
|
69
|
+
|
70
|
+
nil
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
data/lib/completely/version.rb
CHANGED
data/lib/completely.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: completely
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.6.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Danny Ben Shitrit
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-
|
11
|
+
date: 2023-06-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: colsole
|
@@ -62,16 +62,21 @@ files:
|
|
62
62
|
- lib/completely/commands/preview.rb
|
63
63
|
- lib/completely/commands/test.rb
|
64
64
|
- lib/completely/completions.rb
|
65
|
+
- lib/completely/exceptions.rb
|
66
|
+
- lib/completely/installer.rb
|
65
67
|
- lib/completely/pattern.rb
|
66
68
|
- lib/completely/templates/sample.yaml
|
67
69
|
- lib/completely/templates/template.erb
|
68
70
|
- lib/completely/templates/tester-template.erb
|
69
71
|
- lib/completely/tester.rb
|
70
72
|
- lib/completely/version.rb
|
71
|
-
homepage: https://github.com/
|
73
|
+
homepage: https://github.com/DannyBen/completely
|
72
74
|
licenses:
|
73
75
|
- MIT
|
74
76
|
metadata:
|
77
|
+
bug_tracker_uri: https://github.com/DannyBen/completely/issues
|
78
|
+
changelog_uri: https://github.com/DannyBen/completely/blob/master/CHANGELOG.md
|
79
|
+
source_code_uri: https://github.com/DannyBen/completely
|
75
80
|
rubygems_mfa_required: 'true'
|
76
81
|
post_install_message:
|
77
82
|
rdoc_options: []
|
@@ -81,14 +86,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
81
86
|
requirements:
|
82
87
|
- - ">="
|
83
88
|
- !ruby/object:Gem::Version
|
84
|
-
version:
|
89
|
+
version: '3.0'
|
85
90
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
86
91
|
requirements:
|
87
92
|
- - ">="
|
88
93
|
- !ruby/object:Gem::Version
|
89
94
|
version: '0'
|
90
95
|
requirements: []
|
91
|
-
rubygems_version: 3.4.
|
96
|
+
rubygems_version: 3.4.14
|
92
97
|
signing_key:
|
93
98
|
specification_version: 4
|
94
99
|
summary: Bash Completions Generator
|