simple-cli 0.2.3 → 0.2.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 +4 -4
- data/Gemfile.lock +2 -2
- data/lib/simple/cli/runner.rb +37 -14
- data/lib/simple/cli/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d679f9697e51d2d91312bfe3eaac0a6cb577019a
|
4
|
+
data.tar.gz: 0a7cce907a747c8a0b0c44a1c2d4f5e45701f59c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 18fdd30d1a31e77da83a3e549c43d2712f0912121becf6240c528cb8686e3059899d15a06602237bd986493f0d0764eba4edce24c19aa358346ef4be5d3a0bb2
|
7
|
+
data.tar.gz: 0e53ca862abac7db8120d1ec922fe0310f8fcd02f99d5efd09e528565bcd775e171cf91bcff7ee97a22b97844a41f2f2bd9fc8d69ec393924341a08850736308
|
data/Gemfile.lock
CHANGED
data/lib/simple/cli/runner.rb
CHANGED
@@ -134,34 +134,57 @@ class Simple::CLI::Runner
|
|
134
134
|
end
|
135
135
|
|
136
136
|
def help!
|
137
|
-
|
137
|
+
# collect help information on individual comments; when not on DEBUG
|
138
|
+
# level skipping the commands that don't jave a command help.
|
138
139
|
command_helps = commands.inject({}) do |hsh, sym|
|
140
|
+
edoc = CommandHelp.new(@app, sym)
|
141
|
+
next hsh if !edoc.head && logger.level != ::Logger::DEBUG
|
142
|
+
|
139
143
|
hsh.update sym => help_for_command(sym)
|
140
144
|
end
|
141
|
-
max_command_helps_length = command_helps.values.map(&:length).max
|
142
145
|
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
+
# build a lambda which prints a help line with nice formatting
|
147
|
+
max_length = command_helps.values.map(&:length).max
|
148
|
+
print_help_line = lambda do |cmd, description|
|
149
|
+
if description
|
150
|
+
STDERR.puts format(" %-#{max_length}s # %s", cmd, description)
|
151
|
+
else
|
152
|
+
STDERR.puts format(" %-#{max_length}s", cmd)
|
153
|
+
end
|
154
|
+
end
|
155
|
+
|
156
|
+
# print help for commands
|
157
|
+
STDERR.puts "Usage:\n\n"
|
158
|
+
|
159
|
+
command_helps.keys.sort.each do |sym|
|
160
|
+
command_help = command_helps[sym]
|
146
161
|
edoc = CommandHelp.new(@app, sym)
|
147
|
-
|
148
|
-
head = "# #{edoc.head}" if edoc.head
|
149
|
-
STDERR.puts " #{command_help} #{head}"
|
162
|
+
print_help_line.call command_help, edoc.head
|
150
163
|
end
|
151
164
|
|
152
|
-
|
165
|
+
# print help for default commands
|
153
166
|
|
154
167
|
STDERR.puts <<~DOC
|
168
|
+
|
155
169
|
Default options include:
|
156
170
|
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
171
|
+
DOC
|
172
|
+
|
173
|
+
print_help_line.call "#{binary_name} [ --verbose | -v ]", "run on DEBUG log level"
|
174
|
+
print_help_line.call "#{binary_name} [ --quiet | -q ]", "run on WARN log level"
|
175
|
+
|
176
|
+
STDERR.puts <<~DOC
|
177
|
+
|
178
|
+
Other commands:
|
162
179
|
|
163
180
|
DOC
|
164
181
|
|
182
|
+
print_help_line.call "#{binary_name} help [ subcommand ]", "print help on a specific subcommand"
|
183
|
+
print_help_line.call "#{binary_name} help -v", "show help for internal commands as well"
|
184
|
+
print_help_line.call "#{binary_name} help autocomplete", "print information on autocompletion."
|
185
|
+
|
186
|
+
STDERR.puts "\n"
|
187
|
+
|
165
188
|
exit 1
|
166
189
|
end
|
167
190
|
end
|
data/lib/simple/cli/version.rb
CHANGED
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.2.
|
4
|
+
version: 0.2.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- radiospiel
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2018-02
|
12
|
+
date: 2018-03-02 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rake
|