8000 Backport from v0.5.0 to fix a bug #74 by kwatch · Pull Request #78 · ruby/optparse · GitHub
[go: up one dir, main page]

Skip to content

Backport from v0.5.0 to fix a bug #74 #78

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Backport from v0.5.0 to fix a bug #74
  • Loading branch information
kwatch committed Oct 3, 2024
commit 08d639ba6204a8e6633fb962822e70a90f440aae
13 changes: 9 additions & 4 deletions lib/optparse.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1641,14 +1641,19 @@ def parse_in_order(argv = default_argv, setter = nil, &nonopt) # :nodoc:
opt, rest = $1, $2
opt.tr!('_', '-')
begin
sw, = complete(:long, opt, true)
if require_exact && !sw.long.include?(arg)
throw :terminate, arg unless raise_unknown
raise InvalidOption, arg
if require_exact
sw, = search(:long, opt)
else
sw, = complete(:long, opt, true)
end
rescue ParseError
throw :terminate, arg unless raise_unknown
raise $!.set_option(arg, true)
else
unless sw
throw :terminate, arg unless raise_unknown
raise InvalidOption, arg
end
end
begin
opt, cb, val = sw.parse(rest, argv) {|*exc| raise(*exc)}
Expand Down
0