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 +4 -4
- data/lib/optparse2/version.rb +1 -1
- data/lib/optparse2.rb +8 -4
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 231baf4fb3c4a278ea945a8bcff14e90decf66d13b37c25659cfc364ae9c0599
|
|
4
|
+
data.tar.gz: ede27c9be0e8bd48f9efe7358d716015d555a4f26544823354da0f005cb871ae
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 7365315d5bf866353e233f5771057eb709871ad75d320ac979b860d5d6625cdcbb315cdc073eb6a79a0542c33025e320f77bbacde1101f9c641cf4b41dbafb30
|
|
7
|
+
data.tar.gz: 619232fed57b4670346be829b7d4afac06748f117b415eeaabe71be96f57a5870b0d32a8b3b5d222b70b8c432abfeed6b5acf6d701d38c0ca00dc395c221200e
|
data/lib/optparse2/version.rb
CHANGED
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
|
-
|
|
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
|
-
|
|
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
|
|