completely 0.5.4 → 0.6.1
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/cli.rb +3 -1
- data/lib/completely/commands/init.rb +1 -1
- data/lib/completely/commands/install.rb +7 -57
- data/lib/completely/commands/uninstall.rb +39 -0
- data/lib/completely/exceptions.rb +4 -0
- data/lib/completely/installer.rb +86 -0
- data/lib/completely/templates/template.erb +1 -1
- data/lib/completely/version.rb +1 -1
- data/lib/completely.rb +2 -0
- metadata +11 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 96373b5a76365d9d8dd59e017dec1c32159520ac92f4d2abaed7dd807843a847
|
4
|
+
data.tar.gz: fea9ce43a598c7f52ddb59971f895ebdb8eb9bb4f9a1d6918e5c15c52eb583e9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c2b06ef048b16ddc565534b7934c421bc9dde18bf7706071972f64d406563be6044308cd4a38497f96f78208ba5916bc29d5aa4c1228f30fdfb0e6cad638f61b
|
7
|
+
data.tar.gz: ae92c96a9d51cf4574868257432f348494e16c8bbcfa10a3a6703ae6ca3de110a008c443bc1da25807a815792e7e9d7e3cc6df5530a32ee21c5653524662b93d
|
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`
|
data/lib/completely/cli.rb
CHANGED
@@ -1,10 +1,11 @@
|
|
1
1
|
require 'mister_bin'
|
2
|
-
require 'completely/version'
|
3
2
|
require 'completely/commands/generate'
|
4
3
|
require 'completely/commands/init'
|
5
4
|
require 'completely/commands/install'
|
6
5
|
require 'completely/commands/preview'
|
7
6
|
require 'completely/commands/test'
|
7
|
+
require 'completely/commands/uninstall'
|
8
|
+
require 'completely/version'
|
8
9
|
|
9
10
|
module Completely
|
10
11
|
class CLI
|
@@ -18,6 +19,7 @@ module Completely
|
|
18
19
|
runner.route 'generate', to: Commands::Generate
|
19
20
|
runner.route 'test', to: Commands::Test
|
20
21
|
runner.route 'install', to: Commands::Install
|
22
|
+
runner.route 'uninstall', to: Commands::Uninstall
|
21
23
|
|
22
24
|
runner
|
23
25
|
end
|
@@ -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.install_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.install_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,39 @@
|
|
1
|
+
require 'completely/commands/base'
|
2
|
+
|
3
|
+
module Completely
|
4
|
+
module Commands
|
5
|
+
class Uninstall < Base
|
6
|
+
summary 'Uninstall a bash completion script'
|
7
|
+
|
8
|
+
help <<~HELP
|
9
|
+
This command will remove the completion script for the specified program from all the bash completion directories.
|
10
|
+
HELP
|
11
|
+
|
12
|
+
usage 'completely uninstall PROGRAM [--dry]'
|
13
|
+
usage 'completely uninstall (-h|--help)'
|
14
|
+
|
15
|
+
option '-d --dry', 'Show the uninstallation command but do not run it'
|
16
|
+
|
17
|
+
param 'PROGRAM', 'Name of the program the completions are for.'
|
18
|
+
|
19
|
+
def run
|
20
|
+
if args['--dry']
|
21
|
+
puts installer.uninstall_command_string
|
22
|
+
return
|
23
|
+
end
|
24
|
+
|
25
|
+
success = installer.uninstall
|
26
|
+
raise InstallError, "Failed running command:\nnb`#{installer.uninstall_command_string}`" unless success
|
27
|
+
|
28
|
+
say 'Done'
|
29
|
+
say 'You may need to restart your session to test it'
|
30
|
+
end
|
31
|
+
|
32
|
+
private
|
33
|
+
|
34
|
+
def installer
|
35
|
+
Installer.new program: args['PROGRAM']
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
@@ -0,0 +1,86 @@
|
|
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 install_command
|
19
|
+
result = root_user? ? [] : %w[sudo]
|
20
|
+
result + %W[cp #{script_path} #{target_path}]
|
21
|
+
end
|
22
|
+
|
23
|
+
def install_command_string
|
24
|
+
install_command.join ' '
|
25
|
+
end
|
26
|
+
|
27
|
+
def uninstall_command
|
28
|
+
result = root_user? ? [] : %w[sudo]
|
29
|
+
result + %w[rm -f] + target_directories.map { |dir| "#{dir}/#{program}" }
|
30
|
+
end
|
31
|
+
|
32
|
+
def uninstall_command_string
|
33
|
+
uninstall_command.join ' '
|
34
|
+
end
|
35
|
+
|
36
|
+
def target_path
|
37
|
+
"#{completions_path}/#{program}"
|
38
|
+
end
|
39
|
+
|
40
|
+
def install(force: false)
|
41
|
+
unless completions_path
|
42
|
+
raise InstallError, 'Cannot determine system completions directory'
|
43
|
+
end
|
44
|
+
|
45
|
+
unless script_exist?
|
46
|
+
raise InstallError, "Cannot find script: m`#{script_path}`"
|
47
|
+
end
|
48
|
+
|
49
|
+
if target_exist? && !force
|
50
|
+
raise InstallError, "File exists: m`#{target_path}`"
|
51
|
+
end
|
52
|
+
|
53
|
+
system(*install_command)
|
54
|
+
end
|
55
|
+
|
56
|
+
def uninstall
|
57
|
+
system(*uninstall_command)
|
58
|
+
end
|
59
|
+
|
60
|
+
private
|
61
|
+
|
62
|
+
def target_exist?
|
63
|
+
File.exist? target_path
|
64
|
+
end
|
65
|
+
|
66
|
+
def script_exist?
|
67
|
+
File.exist? script_path
|
68
|
+
end
|
69
|
+
|
70
|
+
def root_user?
|
71
|
+
Process.uid.zero?
|
72
|
+
end
|
73
|
+
|
74
|
+
def completions_path
|
75
|
+
@completions_path ||= completions_path!
|
76
|
+
end
|
77
|
+
|
78
|
+
def completions_path!
|
79
|
+
target_directories.each do |target|
|
80
|
+
return target if Dir.exist? target
|
81
|
+
end
|
82
|
+
|
83
|
+
nil
|
84
|
+
end
|
85
|
+
end
|
86
|
+
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.1
|
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
|
@@ -61,17 +61,23 @@ files:
|
|
61
61
|
- lib/completely/commands/install.rb
|
62
62
|
- lib/completely/commands/preview.rb
|
63
63
|
- lib/completely/commands/test.rb
|
64
|
+
- lib/completely/commands/uninstall.rb
|
64
65
|
- lib/completely/completions.rb
|
66
|
+
- lib/completely/exceptions.rb
|
67
|
+
- lib/completely/installer.rb
|
65
68
|
- lib/completely/pattern.rb
|
66
69
|
- lib/completely/templates/sample.yaml
|
67
70
|
- lib/completely/templates/template.erb
|
68
71
|
- lib/completely/templates/tester-template.erb
|
69
72
|
- lib/completely/tester.rb
|
70
73
|
- lib/completely/version.rb
|
71
|
-
homepage: https://github.com/
|
74
|
+
homepage: https://github.com/DannyBen/completely
|
72
75
|
licenses:
|
73
76
|
- MIT
|
74
77
|
metadata:
|
78
|
+
bug_tracker_uri: https://github.com/DannyBen/completely/issues
|
79
|
+
changelog_uri: https://github.com/DannyBen/completely/blob/master/CHANGELOG.md
|
80
|
+
source_code_uri: https://github.com/DannyBen/completely
|
75
81
|
rubygems_mfa_required: 'true'
|
76
82
|
post_install_message:
|
77
83
|
rdoc_options: []
|
@@ -81,14 +87,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
81
87
|
requirements:
|
82
88
|
- - ">="
|
83
89
|
- !ruby/object:Gem::Version
|
84
|
-
version:
|
90
|
+
version: '3.0'
|
85
91
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
86
92
|
requirements:
|
87
93
|
- - ">="
|
88
94
|
- !ruby/object:Gem::Version
|
89
95
|
version: '0'
|
90
96
|
requirements: []
|
91
|
-
rubygems_version: 3.4.
|
97
|
+
rubygems_version: 3.4.14
|
92
98
|
signing_key:
|
93
99
|
specification_version: 4
|
94
100
|
summary: Bash Completions Generator
|