nub 0.0.52 → 0.0.53

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.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/nub/commander.rb +6 -4
  3. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: dbb6012caafc7ba2ef97052b8f8577ab631565d7b5964e111f2a02b52139c092
4
- data.tar.gz: 29895378b9e02eae31af58d792c36406fbee2cc5759ab84dca4ede07bf7015d8
3
+ metadata.gz: af6ff1743615a43ecb53bb050e0f763b9f4974d24beeeb6e53607509c53719a3
4
+ data.tar.gz: fbb637f9cb425e29c38a2cab27d0ba60f49c66831077a9150ae4a96d8b3945af
5
5
  SHA512:
6
- metadata.gz: 2274e48efc5268a48fb3690fa0e85d487dbe69516160bd34fee2f76d10557ba72a1d8fdb42255846b14b1186df0ade53fa51cccec05abf093de17b1ed25964f0
7
- data.tar.gz: 8c74aa5a469e44d0e710143ea3f553cf8d44133dfffc0129d0ccd18ccd4cf2029b2af4b512dae512ec35593a953e4f56bd8d4d6109db65ce0d46a8452a563211
6
+ metadata.gz: 5195e80a5f024b57e4eaf6d667d3dc6e168c1933fa91b998d9781dd7f67c3c5020c941801685faf9a41c761a4c833f0ca330b79bf9fa96d4fc1ecfd86dd919fa
7
+ data.tar.gz: 19bc728c493e1500accf09a4d40eb57db3f117428b6508466a295f70985dbd1cd854f9edc444c2550bb1f48a00199d6dd16e70b939fcd777e64493fb9db7ffe9
data/lib/nub/commander.rb CHANGED
@@ -222,6 +222,12 @@ class Commander
222
222
  opts = ARGV.take_while{|x| !cmd_names.include?(x) }
223
223
  ARGV.shift(opts.size)
224
224
 
225
+ # Handle help upfront before anything else
226
+ if opts.any?{|x| m = match_named(x, cmd); m.hit? && m.sym == :help }
227
+ !puts(help) and exit if cmd.name == 'global'
228
+ !puts(cmd.help) and exit
229
+ end
230
+
225
231
  # Check that all required options were given
226
232
  cmd_pos_opts = cmd.opts.select{|x| x.key.nil? }
227
233
  cmd_named_opts = cmd.opts.select{|x| !x.key.nil? }
@@ -253,10 +259,6 @@ class Commander
253
259
  value = match.value
254
260
  value = match.flag? || opts.shift if !value
255
261
 
256
- # Handle help for the command
257
- !puts(help) and exit if cmd.name == 'global' && match.sym == :help
258
- !puts(cmd.help) and exit if match.sym == :help
259
-
260
262
  # Validate/set positional options
261
263
  # --------------------------------------------------------------------
262
264
  else
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nub
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.52
4
+ version: 0.0.53
5
5
  platform: ruby
6
6
  authors:
7
7
  - Patrick Crummett
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-04-12 00:00:00.000000000 Z
11
+ date: 2018-04-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: colorize