getopt 1.7.0 → 1.7.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: e45a7211aea22472efcebd09ba6aa5b344eac0441213144d6c8c408d0adfabf5
4
- data.tar.gz: 2a95d618c4ededa6de05a091429c85dc38cdd5f43d75618587e5a74d589bcd50
3
+ metadata.gz: e1df233b5fdf5032c1f424f1c3966755f7e16eaf2dc7f14355105bb0afe57d84
4
+ data.tar.gz: 1015a29bc20669f3ae22d4f03cc7d75790b5a31d872f874821ca1d9be1100c3c
5
5
  SHA512:
6
- metadata.gz: ecda8ad35cfaac66dd59c0432796a7901f22f351ee2fd347aff8e4f0a730a5ca963fe428608de5988a7f00bd367c1d3e6b4f3865bc44cb4762a06962b831ca3c
7
- data.tar.gz: 9b5308a4a046cb6df55353114bd396749c75443d75e4c8c1f2c886702420e16a2bb57cec3fc253ee17f2cea9d9dfbad9a2d5e84e60cb984aae09cfa389380962
6
+ metadata.gz: 44fa9976543e80797a085028c5fcb27045c9a7cc093add9b777a6f4705189b29eb2458eb9d46a0a6ae20a958fa39e0f4da17d2362989bae38146b647e451005f
7
+ data.tar.gz: 21947ee37c4e309a6c132db383126577145c6cdb8d86e162c1b7acd37f0ef2be90c8422d5d8a3dbf9dfbf5d9e2f51f2e7eed0055dd37a1940c2193f337878759
checksums.yaml.gz.sig CHANGED
Binary file
data/CHANGES.md CHANGED
@@ -1,4 +1,7 @@
1
- # 1.7.0 - 13-Feb-2026
1
+ # 1.7.1 - 20-May-2026
2
+ * Fixed short option parsing so aliases like `-?` work again. Thanks go to swabianeagle for the spot.
3
+
4
+ ## 1.7.0 - 13-Feb-2026
2
5
  * Added the NEGATABLE option so you can do --no-whatever.
3
6
  * A few warnings were cleaned up, along with rubocop updates.
4
7
  * Some administrative stuff, updated Rakefile, Gemfile, etc.
data/getopt.gemspec CHANGED
@@ -2,7 +2,7 @@ require 'rubygems'
2
2
 
3
3
  Gem::Specification.new do |spec|
4
4
  spec.name = 'getopt'
5
- spec.version = '1.7.0'
5
+ spec.version = '1.7.1'
6
6
  spec.author = 'Daniel J. Berger'
7
7
  spec.license = 'Apache-2.0'
8
8
  spec.email = 'djberg96@gmail.com'
data/lib/getopt/long.rb CHANGED
@@ -94,9 +94,9 @@ module Getopt
94
94
  end
95
95
 
96
96
  re_long = /^(--\w+[-\w+]*)?$/
97
- re_short = /^(-\w)$/
98
- re_long_eq = /^(--\w+[-\w+]*)?=(.*?)$|(-\w?)=(.*?)$/
99
- re_short_sq = /^(-\w)(\S+?)$/
97
+ re_short = /^(-[^\s-])$/
98
+ re_long_eq = /^(--\w+[-\w+]*)?=(.*?)$|(-[^\s-])=(.*?)$/
99
+ re_short_sq = /^(-[^\s-])(\S+?)$/
100
100
 
101
101
  ARGV.each_with_index do |opt, index|
102
102
  # Allow either -x -v or -xv style for single char args
data/lib/getopt/std.rb CHANGED
@@ -46,7 +46,7 @@ module Getopt
46
46
  def self.getopts(switches)
47
47
  args = switches.split(/ */)
48
48
  hash = {}
49
- regex = /^-(\w)\s*(\w*)/s
49
+ regex = /^-([^\s-])\s*(\S*)/s
50
50
 
51
51
  while !ARGV.empty? && regex.match(ARGV.first)
52
52
  first, rest = Regexp.last_match(1), Regexp.last_match(2)
@@ -3,6 +3,6 @@
3
3
  module Getopt
4
4
  module Version
5
5
  # The version of the getopt library
6
- VERSION = '1.7.0'
6
+ VERSION = '1.7.1'
7
7
  end
8
8
  end
@@ -20,7 +20,7 @@ RSpec.describe Getopt::Long do
20
20
  end
21
21
 
22
22
  example 'version' do
23
- expect(Getopt::Long::VERSION).to eq('1.7.0')
23
+ expect(Getopt::Long::VERSION).to eq('1.7.1')
24
24
  expect(Getopt::Long::VERSION).to be_frozen
25
25
  end
26
26
 
@@ -112,6 +112,19 @@ RSpec.describe Getopt::Long do
112
112
  expect(@opts['b']).to eq('world')
113
113
  end
114
114
 
115
+ example 'getopts long accepts question mark as a short switch' do
116
+ ARGV.push('-?')
117
+
118
+ expect{
119
+ @opts = described_class.getopts(
120
+ ['--help', '-?', Getopt::BOOLEAN]
121
+ )
122
+ }.not_to raise_error
123
+
124
+ expect(@opts['help']).to be(true)
125
+ expect(@opts['?']).to be(true)
126
+ end
127
+
115
128
  example 'getopts long increment type works as expected' do
116
129
  ARGV.push('-m', '-m')
117
130
 
@@ -15,7 +15,7 @@ RSpec.describe Getopt::Std do
15
15
  end
16
16
 
17
17
  example 'version' do
18
- expect(described_class::VERSION).to eq('1.7.0')
18
+ expect(described_class::VERSION).to eq('1.7.1')
19
19
  expect(described_class::VERSION).to be_frozen
20
20
  end
21
21
 
@@ -59,6 +59,11 @@ RSpec.describe Getopt::Std do
59
59
  expect(described_class.getopts('ID')).to eq({'I' => true, 'D' => true})
60
60
  end
61
61
 
62
+ example 'getopts accepts question mark as a switch' do
63
+ ARGV.push('-?')
64
+ expect(described_class.getopts('?')).to eq({'?' => true})
65
+ end
66
+
62
67
  example 'getopts with separated switches and mandatory argument' do
63
68
  ARGV.push('-o', 'hello', '-I', '-D')
64
69
  expect(described_class.getopts('o:ID')).to eq({'o' => 'hello', 'I' => true, 'D' => true})
data.tar.gz.sig CHANGED
Binary file
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: getopt
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.7.0
4
+ version: 1.7.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Daniel J. Berger
@@ -147,7 +147,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
147
147
  - !ruby/object:Gem::Version
148
148
  version: '0'
149
149
  requirements: []
150
- rubygems_version: 4.0.3
150
+ rubygems_version: 4.0.6
151
151
  specification_version: 4
152
152
  summary: Getopt::Std and Getopt::Long option parsers for Ruby
153
153
  test_files:
metadata.gz.sig CHANGED
Binary file