completely 0.5.2 → 0.5.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7928212af575e203b41b2b6a1c94a0f6f564c28ae44795ade142b41ed83cbfe7
4
- data.tar.gz: 541bd497455eedd5b0114edb7913ed1ccb1d2cfc90d78ca6d45298864f210583
3
+ metadata.gz: e4fbe4bb19567637239bac887b5e785caeac6c0dbf38f82e7d775a994db58a29
4
+ data.tar.gz: d7449fd83d8e1b6e5ce723deb457e6e8eab4254a92818f739fd6002b939385c8
5
5
  SHA512:
6
- metadata.gz: cccadd0753d2ba83700f9bdebbd8e29eb3519206bb99992636fdde98cc313107b6475b8c12291dac3be8cbfc9ee235fa59c512dd55b62c2d8027ab871d8d424c
7
- data.tar.gz: 36997d82e3438909788eb70484aabcaebe7a37534039ce748c1f3257aef05a674a8a9110280b3b324622eea1ff749263ea2a9968e31708be050676549536efcb
6
+ metadata.gz: e5e3c3985ac71d2db26ce7f321e1717af80ef760def41820b86e505ee884a3921d43618093c94ee41b3f9ed2291d35f9eac49fd6c4c6d4a376e1e981198d3ce9
7
+ data.tar.gz: 19719cecb29e21e1a226fd45d815a02baf9579c75e0f88ed0876a4ece8c3dee587feb88e71657d9d362cf9a2de5d0222b1423ecff4af759d32906daee0ba42a7
data/bin/completely CHANGED
@@ -10,6 +10,6 @@ begin
10
10
  exit runner.run ARGV
11
11
  rescue => e
12
12
  puts e.backtrace.reverse if ENV['DEBUG']
13
- say! "!undred!#{e.class}!txtrst!\n#{e.message}"
13
+ say! "rib` #{e.class} `\n#{e.message}"
14
14
  exit 1
15
15
  end
@@ -1,21 +1,23 @@
1
1
  require 'mister_bin'
2
+ require 'completely/version'
3
+ require 'completely/commands/generate'
2
4
  require 'completely/commands/init'
5
+ require 'completely/commands/install'
3
6
  require 'completely/commands/preview'
4
- require 'completely/commands/generate'
5
7
  require 'completely/commands/test'
6
- require 'completely/version'
7
8
 
8
9
  module Completely
9
10
  class CLI
10
11
  def self.runner
11
12
  runner = MisterBin::Runner.new version: Completely::VERSION,
12
13
  header: 'Completely - Bash Completions Generator',
13
- footer: 'Run !txtpur!completely COMMAND --help!txtrst! for more information'
14
+ footer: 'Run m`completely COMMAND --help` for more information'
14
15
 
15
16
  runner.route 'init', to: Commands::Init
16
17
  runner.route 'preview', to: Commands::Preview
17
18
  runner.route 'generate', to: Commands::Generate
18
19
  runner.route 'test', to: Commands::Test
20
+ runner.route 'install', to: Commands::Install
19
21
 
20
22
  runner
21
23
  end
@@ -51,8 +51,8 @@ module Completely
51
51
  end
52
52
 
53
53
  def syntax_warning
54
- say! "\n!txtred!WARNING:\nYour configuration is invalid."
55
- say! '!txtred!All patterns must start with the same word.'
54
+ say! "\nr`WARNING:`\nr`Your configuration is invalid.`"
55
+ say! 'r`All patterns must start with the same word.`'
56
56
  end
57
57
  end
58
58
  end
@@ -27,7 +27,7 @@ module Completely
27
27
  wrap = args['--wrap']
28
28
  output = wrap ? wrapper_function(wrap) : script
29
29
  File.write output_path, output
30
- say "Saved !txtpur!#{output_path}"
30
+ say "Saved m`#{output_path}`"
31
31
  syntax_warning unless completions.valid?
32
32
  end
33
33
 
@@ -15,7 +15,7 @@ module Completely
15
15
  raise "File already exists: #{config_path}" if File.exist? config_path
16
16
 
17
17
  File.write config_path, sample
18
- say "Saved !txtpur!#{config_path}"
18
+ say "Saved m`#{config_path}`"
19
19
  end
20
20
 
21
21
  private
@@ -0,0 +1,96 @@
1
+ require 'completely/commands/base'
2
+
3
+ module Completely
4
+ module Commands
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
+ summary 'Install a bash completion script'
13
+
14
+ help <<~HELP
15
+ This command will copy the specified file to one of the following directories:
16
+
17
+ #{TARGETS.map { |c| " - #{c}" }.join "\n"}
18
+
19
+ The target filename will be the program name, and sudo will be used if necessary.
20
+ HELP
21
+
22
+ usage 'completely install PROGRAM [SCRIPT_PATH --force --dry]'
23
+ usage 'completely install (-h|--help)'
24
+
25
+ option '-f --force', 'Overwrite target file if it exists'
26
+ option '-d --dry', 'Show the installation command but do not run it'
27
+
28
+ param 'PROGRAM', 'Name of the program the completions are for.'
29
+ param 'SCRIPT_PATH', 'Path to the source bash script [default: completely.bash].'
30
+
31
+ def run
32
+ bounce
33
+
34
+ if args['--dry']
35
+ puts command.join ' '
36
+ return
37
+ end
38
+
39
+ success = system(*command)
40
+ raise "Failed running command:\nnb`#{command.join ' '}`" unless success
41
+
42
+ say "Saved m`#{target_path}`"
43
+ say 'You may need to restart your session to test it'
44
+ end
45
+
46
+ private
47
+
48
+ def bounce
49
+ unless completions_path
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}]
69
+ end
70
+
71
+ def script_path
72
+ args['SCRIPT_PATH'] || 'completely.bash'
73
+ 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
+ end
95
+ end
96
+ end
@@ -38,14 +38,14 @@ module Completely
38
38
 
39
39
  def show_compline(compline, filename: nil)
40
40
  filename ||= 'completely-tester.sh'
41
- say "!txtblu!$ !txtgrn!#{compline}!txtrst!<tab>"
41
+ say "b`$` g`#{compline}`<tab>"
42
42
  puts tester.test(compline).join "\n"
43
43
  puts
44
44
 
45
45
  return unless keep
46
46
 
47
47
  File.write filename, tester_script(compline)
48
- say "Saved !txtpur!#{filename}"
48
+ say "Saved m`#{filename}`"
49
49
  end
50
50
 
51
51
  def complines
@@ -1,3 +1,3 @@
1
1
  module Completely
2
- VERSION = '0.5.2'
2
+ VERSION = '0.5.4'
3
3
  end
metadata CHANGED
@@ -1,43 +1,49 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: completely
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.2
4
+ version: 0.5.4
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: 2022-12-02 00:00:00.000000000 Z
11
+ date: 2023-04-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: colsole
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - "~>"
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: 0.8.1
20
+ - - "<"
18
21
  - !ruby/object:Gem::Version
19
- version: '0.6'
22
+ version: '2'
20
23
  type: :runtime
21
24
  prerelease: false
22
25
  version_requirements: !ruby/object:Gem::Requirement
23
26
  requirements:
24
- - - "~>"
27
+ - - ">="
28
+ - !ruby/object:Gem::Version
29
+ version: 0.8.1
30
+ - - "<"
25
31
  - !ruby/object:Gem::Version
26
- version: '0.6'
32
+ version: '2'
27
33
  - !ruby/object:Gem::Dependency
28
34
  name: mister_bin
29
35
  requirement: !ruby/object:Gem::Requirement
30
36
  requirements:
31
37
  - - "~>"
32
38
  - !ruby/object:Gem::Version
33
- version: 0.7.2
39
+ version: '0.7'
34
40
  type: :runtime
35
41
  prerelease: false
36
42
  version_requirements: !ruby/object:Gem::Requirement
37
43
  requirements:
38
44
  - - "~>"
39
45
  - !ruby/object:Gem::Version
40
- version: 0.7.2
46
+ version: '0.7'
41
47
  description: Generate bash completion scripts using simple YAML configuration
42
48
  email: db@dannyben.com
43
49
  executables:
@@ -52,6 +58,7 @@ files:
52
58
  - lib/completely/commands/base.rb
53
59
  - lib/completely/commands/generate.rb
54
60
  - lib/completely/commands/init.rb
61
+ - lib/completely/commands/install.rb
55
62
  - lib/completely/commands/preview.rb
56
63
  - lib/completely/commands/test.rb
57
64
  - lib/completely/completions.rb
@@ -81,7 +88,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
81
88
  - !ruby/object:Gem::Version
82
89
  version: '0'
83
90
  requirements: []
84
- rubygems_version: 3.3.26
91
+ rubygems_version: 3.4.12
85
92
  signing_key:
86
93
  specification_version: 4
87
94
  summary: Bash Completions Generator