optparse2 0.7.1 → 0.7.3

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3ccf871ad692772fb4e40ece995b2a812812d3416c51ead37d0fceea9a4b959f
4
- data.tar.gz: eb74c3439fea8f47b70497d2f78e74849aa0cdc15ee2d25ec123b38710d7dea0
3
+ metadata.gz: 231baf4fb3c4a278ea945a8bcff14e90decf66d13b37c25659cfc364ae9c0599
4
+ data.tar.gz: ede27c9be0e8bd48f9efe7358d716015d555a4f26544823354da0f005cb871ae
5
5
  SHA512:
6
- metadata.gz: a01534549e3a919e0fa7d5c89d41ceb334d1d375d1a9b436a1e25efdb61c5aaf568ec46ee74e549607280cf6bfef12e40824b5c52eceae9a54138c565f7a8106
7
- data.tar.gz: 211b3b24d8888ac8c802d2fe7aaf3dfbe134e9adf3fa2bdcb86a3c5c78adf8cef18f0c40b2ef45bdce4db48cd4efe0e55d7c0faa478bcd5fb1e5e10b077c2ae4
6
+ metadata.gz: 7365315d5bf866353e233f5771057eb709871ad75d320ac979b860d5d6625cdcbb315cdc073eb6a79a0542c33025e320f77bbacde1101f9c641cf4b41dbafb30
7
+ data.tar.gz: 619232fed57b4670346be829b7d4afac06748f117b415eeaabe71be96f57a5870b0d32a8b3b5d222b70b8c432abfeed6b5acf6d701d38c0ca00dc395c221200e
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  class OptParse2
4
- VERSION = "0.7.1"
4
+ VERSION = "0.7.3"
5
5
  end
data/lib/optparse2.rb CHANGED
@@ -103,7 +103,7 @@ class OptParse2
103
103
  # Fetch all positional arguments using the same option parsing code
104
104
  old_raise, self.raise_unknown = self.raise_unknown, false
105
105
  begin
106
- p _super_order!(argv, into: context, **keywords)
106
+ _super_order!(argv, into: context, **keywords)
107
107
  rescue OptParse::InvalidArgument => err
108
108
  err.args[0] = @positional[err.args[0][/\d+/].to_i].name
109
109
  raise
@@ -152,7 +152,7 @@ class OptParse2
152
152
  end
153
153
  end
154
154
 
155
- def order!(argv = default_argv, into: nil, **keywords, &nonopt)
155
+ def order!(argv = default_argv, into: nil, abort: false, **keywords, &nonopt)
156
156
  Context.with_context into:, nonopt: do |context|
157
157
 
158
158
  # Parse all normal options in the command line
@@ -179,6 +179,8 @@ class OptParse2
179
179
  # Replace the original argv with the resulting options
180
180
  argv.replace not_matched_options
181
181
  end
182
+ rescue OptionParser::ParseError => err
183
+ abort ? abort(err) : raise
182
184
  end
183
185
 
184
186
  module Positional
@@ -235,7 +237,9 @@ class OptParse2
235
237
 
236
238
  attr_accessor :pos_set_banner
237
239
  def pos(name, *a, key: name, **b, &block)
238
- banner.concat " #{name}" if pos_set_banner
240
+ if pos_set_banner
241
+ banner.concat " #{b[:required] ? '' : '['}#{name}#{b[:required] ? '' : ']'}"
242
+ end
239
243
 
240
244
  sw, *rest = make_switch ["--*-positional-#{@positional.length} #{name}", *a], block, key:, **b
241
245
  sw.extend Positional
@@ -283,7 +287,7 @@ OptParse2.new do |op|
283
287
  p x
284
288
  end
285
289
 
286
- op.parse! %w[ -vvv --foo=abc --bar=123 --foo=xyz -a3 -a4 -a5 ], into: opts={}
290
+ op.parse! %w[ -vvv -q --foo=abc --bar=123 --foo=xyz -a3 -a4 -a5 ], into: opts={}
287
291
  p opts
288
292
  end
289
293
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: optparse2
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.1
4
+ version: 0.7.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - SamW