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 +4 -4
- data/Gemfile.lock +1 -1
- data/lib/simple/cli.rb +0 -6
- data/lib/simple/cli/runner.rb +4 -4
- data/lib/simple/cli/runner/autocompletion.rb +4 -2
- data/lib/simple/cli/runner/command_help.rb +1 -0
- data/lib/simple/cli/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: dd65b05c653ffc6f25c973391b1cc49fc866a332
|
4
|
+
data.tar.gz: 1626dddaf85fa792a31598a30f7b109bf65e8ff9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d88d1e1c20bed12c969ae7eb8462627c7dd9fdc622ad7a0980b98ea2dd18b45b34fa8b62c2a6699ac5d779e51462d3c1df70da49faa8edc59326874f869a9618
|
7
|
+
data.tar.gz: a3f9bc313cfb3f0b2d1edeba0e768c4847013cd50b77d55a867f2e0efa7fdc97b98788c1b74bf8ac75a31fac6359cedb311580363c1c678f2989e64adf1913f3
|
data/Gemfile.lock
CHANGED
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
|
data/lib/simple/cli/runner.rb
CHANGED
@@ -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]+$/)
|
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
|
-
|
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
|
-
|
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
|
data/lib/simple/cli/version.rb
CHANGED