simple-cli 0.2.3 → 0.2.4

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: d2bbb7f97dbbfd4da167b579db74edf64e58f696
4
- data.tar.gz: 3fa71c9effb4830a2542d11562767c67da9f2f95
3
+ metadata.gz: d679f9697e51d2d91312bfe3eaac0a6cb577019a
4
+ data.tar.gz: 0a7cce907a747c8a0b0c44a1c2d4f5e45701f59c
5
5
  SHA512:
6
- metadata.gz: dbf7773b19c487d395706b84b9ea35d59ff9fd11b63b2adf2624375d0212d9ceec8ea55b154f68be4e71fb16ec06f9d177ad178f15a34b464298c5908e1ab0b7
7
- data.tar.gz: f6ee3a7d40c9dd6eb3849625294b17c2cbe5f096b5d7c78a34b0292a67af436fefb12e60b6997acddd3c0f9d36d66d4218064690413ac8495acd9bb0c5511497
6
+ metadata.gz: 18fdd30d1a31e77da83a3e549c43d2712f0912121becf6240c528cb8686e3059899d15a06602237bd986493f0d0764eba4edce24c19aa358346ef4be5d3a0bb2
7
+ data.tar.gz: 0e53ca862abac7db8120d1ec922fe0310f8fcd02f99d5efd09e528565bcd775e171cf91bcff7ee97a22b97844a41f2f2bd9fc8d69ec393924341a08850736308
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- simple-cli (0.2.3)
4
+ simple-cli (0.2.4)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
@@ -55,4 +55,4 @@ DEPENDENCIES
55
55
  simplecov (~> 0)
56
56
 
57
57
  BUNDLED WITH
58
- 1.13.6
58
+ 1.16.1
@@ -134,34 +134,57 @@ class Simple::CLI::Runner
134
134
  end
135
135
 
136
136
  def help!
137
- STDERR.puts "Usage:\n\n"
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
- commands.sort.each do |sym|
144
- command_help = command_helps.fetch(sym)
145
- command_help = format("%-#{max_command_helps_length}s", command_help)
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
- next if !edoc.head && logger.level != ::Logger::DEBUG
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
- STDERR.puts "\n"
165
+ # print help for default commands
153
166
 
154
167
  STDERR.puts <<~DOC
168
+
155
169
  Default options include:
156
170
 
157
- #{binary_name} [ --verbose | -v ] # run on DEBUG log level
158
- #{binary_name} [ --quiet | -q ] # run on WARN log level
159
- #{binary_name} help [ subcommand ] # print help on a specific subcommand
160
- #{binary_name} help autocomplete # print information on autocompletion.
161
- #{binary_name} help -v # show help for internal commands as well
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
@@ -1,5 +1,5 @@
1
1
  module Simple
2
2
  module CLI
3
- VERSION = "0.2.3"
3
+ VERSION = "0.2.4"
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.2.3
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-18 00:00:00.000000000 Z
12
+ date: 2018-03-02 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rake