xoptparse 0.5.0 → 0.6.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: 4ba4ac7ea8acae37ac7b9a7d824d6bb1e0c71e38eefcad9d51ae2b577bd2637b
4
- data.tar.gz: b46b96861f8273625d5934b06e3db2b01831015ee611a1c9a9ab6e46e8febf5e
3
+ metadata.gz: b67b857f7260f74d4f14c343279a3bb75002061470b49473206c95ad5cd38816
4
+ data.tar.gz: 3d7056c4e16be3b0f6b71cb85cacc39481ee9523ce427840dc960126c3ddfbba
5
5
  SHA512:
6
- metadata.gz: 694618d261b60dc6e25f319d208e6f994d86362ee561dfaf754b8174a37611fe2653c41805dc5b257d505c82e52d9801b414c8ecef6bbc28465ea7dbe15ae0c2
7
- data.tar.gz: 1a91cac3019d7509b23d564e92428014cbe44dc40f7fec7db556407ec97aabc73bcfc858715cb8e3c7d3c6a67772070bd7488d60cfb810f785330cfd387f297b
6
+ metadata.gz: a6c00977cccfead1e09cdde9b40592a7a5ef23777c516fbd65332f2a08a50a42f94bf669c4bc89f42e5c84ed427fe61dae5544cc2c33e3c0e8db3f4147b0505c
7
+ data.tar.gz: 3f63f73775990580eb2496a7b99975d94f7d5f773acc3ae4c2cdaae1acaa5930cd24212d555ed1f59229853e2d47f0d8c7bd10368351c306ca21c0e3e9fac8b1
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- xoptparse (0.5.0)
4
+ xoptparse (0.6.1)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
@@ -114,7 +114,7 @@ class XOptionParser < ::OptionParser
114
114
  val = sw.block.call(*a)
115
115
  setter&.call(sw.switch_name, val)
116
116
  end
117
- elsif sw.arg == argv.first
117
+ elsif sw.pattern =~ argv.first
118
118
  argv.shift
119
119
  @command_switch = sw
120
120
  break
@@ -156,14 +156,16 @@ class XOptionParser < ::OptionParser
156
156
  end
157
157
 
158
158
  def command(name, desc = nil, *args, &block)
159
- sw0 = Switch::SummarizeArgument.new(nil, nil, nil, nil, name.to_s, desc ? [desc] : [], nil) do
159
+ name = name.to_s
160
+ pattern = /^#{name.gsub('_', '[-_]?')}$/i
161
+ sw0 = Switch::SummarizeArgument.new(pattern, nil, nil, nil, name, desc ? [desc] : [], nil) do
160
162
  self.class.new(desc, *args) do |opt|
161
163
  opt.program_name = "#{program_name} #{name}"
162
164
  block&.call(opt)
163
165
  end
164
166
  end
165
167
  top.append(sw0, nil, [sw0.arg])
166
- @commands[name.to_s] = sw0
168
+ @commands[name] = sw0
167
169
  nil
168
170
  end
169
171
 
@@ -242,11 +244,11 @@ class XOptionParser < ::OptionParser
242
244
 
243
245
  class FlagArgument < PlacedArgument
244
246
  def parse(arg, argv, &error)
245
- if !arg && (argv.empty? || /\A-/ =~ argv[0])
246
- conv_arg(arg)
247
- else
248
- super(arg, argv, &error)
247
+ super(arg, argv, &error).tap do |val|
248
+ raise OptionParser::InvalidArgument if val[0].nil? && val[2].nil?
249
249
  end
250
+ rescue OptionParser::InvalidArgument
251
+ conv_arg(arg)
250
252
  end
251
253
  end
252
254
  end
@@ -3,5 +3,5 @@
3
3
  require 'optparse'
4
4
 
5
5
  class XOptionParser < ::OptionParser
6
- VERSION = '0.5.0'
6
+ VERSION = '0.6.1'
7
7
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: xoptparse
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.0
4
+ version: 0.6.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - ofk
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-07-15 00:00:00.000000000 Z
11
+ date: 2020-08-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler