optparse2 0.5.0 → 0.5.1

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: 96e00ac7534cbe1b11eff82f027568f5b37339cb562dd2aefc5640134ee98f7f
4
- data.tar.gz: 043042d6dd8c2c207da95355d317a6df45c758c48d98f444fc1ba5b7f29b82e1
3
+ metadata.gz: 376bbfd9fc2c5c6c0be54659a67b7348e25020e9fc127241d99572731ab3242f
4
+ data.tar.gz: 8e11e2b03a970cd1f1de7ef5fe546eb02e49b0c7c536ccf297bdedb4162f2238
5
5
  SHA512:
6
- metadata.gz: bafcec132c0791ce7121c0b3e3d6c290e239ab78a687e799eba07fd3299db17fbfc96a7b14fd555fa5ecf3f01cb841e02dc3e6f2829e4e84edeecd3226258622
7
- data.tar.gz: cec1c603fd5dda235644bd1fb3298dd9a0e57e1f91b45cb762c9bc06b809298656eee7cd71d234257fb316209cfc0b860f4f070a067a06968e0afc2024515577
6
+ metadata.gz: 5f675f1b0ea86836d55639bbf4a97721b686a570a6a4c3e1b57995515f1138d925dd07c6eae266dbbedb22645b124841a33e0770d9523d27fbdeb45b5b2adc15
7
+ data.tar.gz: f8121ecfff0b7e7bacde7649729cdf13f828b63d146f838749184ee362839157338a2939813bad5737c0c85ba1268bb0985baebef0c18330bc6f435cf99b977a
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  class OptParse2
4
- VERSION = "0.5.0"
4
+ VERSION = "0.5.1"
5
5
  end
data/lib/optparse2.rb CHANGED
@@ -121,7 +121,7 @@ class OptParse2
121
121
 
122
122
  result = super(argv, into: already_done, **keywords, &non_options.method(:<<))
123
123
 
124
- argv2 = non_options.each_with_index.flat_map { ["--*-positional-#{_2}", _1] }
124
+ argv2 = (non_options + result).each_with_index.flat_map { ["--*-positional-#{_2}", _1] }
125
125
 
126
126
  old_raise, self.raise_unknown = self.raise_unknown, false
127
127
  begin
@@ -141,7 +141,8 @@ class OptParse2
141
141
  end
142
142
 
143
143
  argv2 = @rest[:block] ? @rest[:block].call(argv2) : argv2
144
- into[@rest[:key]] = argv2 if @rest[:key]
144
+ into[@rest[:key]] = argv2.dup if @rest[:key]
145
+ argv2.clear
145
146
  elsif !argv2.empty? && self.raise_unknown && !@positional.empty?
146
147
  raise ParseError, "got unexpected positional argument: #{argv2.first}", caller(1)
147
148
  else
@@ -245,7 +246,7 @@ require_relative 'optparse2/pathname'
245
246
 
246
247
  # $* << '-tFOO' << '--no-cache' << '-x'
247
248
  # $*.replace %w[123 lol what -t10 is up here]
248
- $*.replace %w[1 -t3 b lol what is up]
249
+ $*.replace %w[1 -t3 bb lol what -- is up]
249
250
 
250
251
  OPTS={}
251
252
  OptParse2.new do |op|
@@ -255,6 +256,6 @@ OptParse2.new do |op|
255
256
  op.pos '[start[-end]]', 'things to do', key: 'line', default: 123
256
257
 
257
258
  op.rest 'branch name', 'Message to submit', 'pretty coo', required: 1 do it.join ' ' end
258
- op.parse! into: OPTS
259
+ p op.parse! into: OPTS
259
260
  p ["finish: ", OPTS, $*]
260
261
  end
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.5.0
4
+ version: 0.5.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - SamW