diff options
| author | fatkodima <fatkodima123@gmail.com> | 2023-10-14 21:52:01 +0300 |
|---|---|---|
| committer | git <svn-admin@ruby-lang.org> | 2024-02-09 03:31:13 +0000 |
| commit | f7a407cabda6eb787fb95fc6e3c1b2215b1aec19 (patch) | |
| tree | 2de17790b0b88d1fe85b57e7db7e03201b2ec83f /lib | |
| parent | 50bcaa62868d806ae861c9dc3353e1f4e85a99f6 (diff) | |
[ruby/optparse] Fix `require_exact` to work with options defined as `--[no]-something`
https://github.com/ruby/optparse/commit/4e346ad337
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/optparse.rb | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/lib/optparse.rb b/lib/optparse.rb index ecf6adc45f..ccfea6dcf0 100644 --- a/lib/optparse.rb +++ b/lib/optparse.rb @@ -1048,7 +1048,7 @@ XXX # Shows option summary. # Officious['help'] = proc do |parser| - Switch::NoArgument.new do |arg| + Switch::NoArgument.new(nil, nil, ["-h"], ["--help"]) do |arg| puts parser.help exit end @@ -1473,7 +1473,7 @@ XXX default_style = default_style.guess(arg = a) default_pattern, conv = search(:atype, o) unless default_pattern end - ldesc << "--[no-]#{q}" + ldesc << "--#{q}" << "--no-#{q}" (o = q.downcase).tr!('_', '-') long << o not_pattern, not_conv = search(:atype, FalseClass) unless not_style @@ -1649,7 +1649,7 @@ XXX opt.tr!('_', '-') begin sw, = complete(:long, opt, true) - if require_exact && !sw.long.include?(arg) + if require_exact && !sw.long.include?("--#{opt}") throw :terminate, arg unless raise_unknown raise InvalidOption, arg end |
