simple-cli 0.1.2 → 0.1.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 1d1cca86fa6b4673bc090dfbbe4ceec9f64a9ab3
4
- data.tar.gz: deec7baa1fb6c0813f6cd957f162c2df880f2d0b
3
+ metadata.gz: dd65b05c653ffc6f25c973391b1cc49fc866a332
4
+ data.tar.gz: 1626dddaf85fa792a31598a30f7b109bf65e8ff9
5
5
  SHA512:
6
- metadata.gz: f905d9b12e0fe61077e78b7ba6e682dc7a4f40ae07b1fff07c17f64fd4e80d2b3c478bdb1a8beb5cde07f7e9d2f5ef57f6dbf8f311b77f5df7575fa26e6dcdb2
7
- data.tar.gz: c01ea85117b23c6dfc08c63bbc355abe1b180ae1cfb80ed2acf6f217dc5a4cecc3f1e3689c4505748db8ffc3817c51cafdee3086a92a5add1f7a6432582d9b49
6
+ metadata.gz: d88d1e1c20bed12c969ae7eb8462627c7dd9fdc622ad7a0980b98ea2dd18b45b34fa8b62c2a6699ac5d779e51462d3c1df70da49faa8edc59326874f869a9618
7
+ data.tar.gz: a3f9bc313cfb3f0b2d1edeba0e768c4847013cd50b77d55a867f2e0efa7fdc97b98788c1b74bf8ac75a31fac6359cedb311580363c1c678f2989e64adf1913f3
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- simple-cli (0.1.2)
4
+ simple-cli (0.1.3)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
data/lib/simple/cli.rb CHANGED
@@ -31,10 +31,4 @@ module Simple::CLI
31
31
  def run!(command, *args)
32
32
  send(command, *args)
33
33
  end
34
-
35
- # Print help on a subcommand
36
- def help(subcommand = nil)
37
- # This method is a dummy. It is necessary to provide a stub for the purpose
38
- # of documentation - BUT THIS METHOD WILL NEVER BE CALLED.
39
- end
40
34
  end
@@ -65,7 +65,7 @@ class Simple::CLI::Runner
65
65
  end
66
66
 
67
67
  def help_subcommand!(subcommand)
68
- edoc = CommandHelp.new(@app, subcommand)
68
+ edoc = CommandHelp.new(@app, string_to_command(subcommand))
69
69
 
70
70
  puts <<~MSG
71
71
  #{help_for_command(subcommand)}
@@ -118,7 +118,7 @@ class Simple::CLI::Runner
118
118
  end
119
119
 
120
120
  def commands
121
- @app.public_instance_methods(false).grep(/^[_a-zA-Z0-9]+$/) + [:help]
121
+ @app.public_instance_methods(false).grep(/^[_a-zA-Z0-9]+$/)
122
122
  end
123
123
 
124
124
  def help_for_command(sym)
@@ -127,8 +127,7 @@ class Simple::CLI::Runner
127
127
  return
128
128
  end
129
129
 
130
- command_name = command_to_string(sym)
131
- CommandHelp.new(@app, sym).interface(binary_name, command_name)
130
+ CommandHelp.new(@app, sym).interface(binary_name, string_to_command(sym))
132
131
  end
133
132
 
134
133
  def binary_name
@@ -157,6 +156,7 @@ class Simple::CLI::Runner
157
156
 
158
157
  #{binary_name} [ --verbose | -v ] # run on DEBUG log level
159
158
  #{binary_name} [ --quiet | -q ] # run on WARN log level
159
+ #{binary_name} help [ subcommand ] # print help on a specific subcommand
160
160
  #{binary_name} help autocomplete # print information on autocompletion.
161
161
 
162
162
  DOC
@@ -20,7 +20,9 @@ module Simple::CLI::Runner::Autocompletion
20
20
  end
21
21
 
22
22
  def autocomplete_subcommands(cur)
23
- completions = filter_completions commands.map(&:to_s), prefix: cur
23
+ commands = self.commands.map { |cmd| cmd.to_s.tr("_", ":") }
24
+ commands << "help"
25
+ completions = filter_completions commands, prefix: cur
24
26
  if completions == [cur]
25
27
  autocomplete_subcommand_options(cur, nil)
26
28
  else
@@ -32,7 +34,7 @@ module Simple::CLI::Runner::Autocompletion
32
34
  completions = if subcommand == "help"
33
35
  commands.map(&:to_s) + ["autocomplete"]
34
36
  else
35
- CommandHelp.option_names(@app, subcommand)
37
+ CommandHelp.option_names(@app, string_to_command(subcommand))
36
38
  end
37
39
 
38
40
  filter_completions completions, prefix: cur
@@ -10,6 +10,7 @@ class Simple::CLI::Runner::CommandHelp
10
10
  end
11
11
 
12
12
  def initialize(mod, method)
13
+ raise(ArgumentError) unless method.is_a?(Symbol)
13
14
  @mod = mod
14
15
  @method = method
15
16
  end
@@ -1,5 +1,5 @@
1
1
  module Simple
2
2
  module CLI
3
- VERSION = "0.1.2"
3
+ VERSION = "0.1.3"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: simple-cli
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - radiospiel