mirror of
https://github.com/ruby/ruby.git
synced 2025-08-15 13:39:04 +02:00
[ruby/optparse] Add raise_unknown
flag
(https://github.com/ruby/optparse/pull/38)
12529653cd
This commit is contained in:
parent
dcf94e719c
commit
0bfb185654
2 changed files with 19 additions and 0 deletions
|
@ -1148,6 +1148,7 @@ XXX
|
|||
@summary_indent = indent
|
||||
@default_argv = ARGV
|
||||
@require_exact = false
|
||||
@raise_unknown = true
|
||||
add_officious
|
||||
yield self if block_given?
|
||||
end
|
||||
|
@ -1225,6 +1226,9 @@ XXX
|
|||
# abbreviated long option as short option).
|
||||
attr_accessor :require_exact
|
||||
|
||||
# Whether to raise at unknown option.
|
||||
attr_accessor :raise_unknown
|
||||
|
||||
#
|
||||
# Heading banner preceding summary.
|
||||
#
|
||||
|
@ -1639,9 +1643,11 @@ XXX
|
|||
begin
|
||||
sw, = complete(:long, opt, true)
|
||||
if require_exact && !sw.long.include?(arg)
|
||||
throw :terminate, arg unless raise_unknown
|
||||
raise InvalidOption, arg
|
||||
end
|
||||
rescue ParseError
|
||||
throw :terminate, arg unless raise_unknown
|
||||
raise $!.set_option(arg, true)
|
||||
end
|
||||
begin
|
||||
|
@ -1673,6 +1679,7 @@ XXX
|
|||
end
|
||||
end
|
||||
rescue ParseError
|
||||
throw :terminate, arg unless raise_unknown
|
||||
raise $!.set_option(arg, true)
|
||||
end
|
||||
begin
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue