diff options
author | Nobuyoshi Nakada <[email protected]> | 2021-03-29 16:42:49 +0900 |
---|---|---|
committer | Nobuyoshi Nakada <[email protected]> | 2021-03-29 19:37:24 +0900 |
commit | e8317d90b0b102ba270b456cc6cb7c6865c6b448 (patch) | |
tree | 0889564769d0de1db072887223ce2e386c6d8ca6 /lib | |
parent | 2bbae0e91acf1090bbcea49476ef007162ec8e2b (diff) |
[ruby/optparse] Fixed error message of unparsed non-option
Close https://github.com/ruby/optparse/issues/3
https://github.com/ruby/optparse/commit/94c5cf4032
Diffstat (limited to 'lib')
-rw-r--r-- | lib/optparse.rb | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/lib/optparse.rb b/lib/optparse.rb index 8b0991506a..ad20ce77a4 100644 --- a/lib/optparse.rb +++ b/lib/optparse.rb @@ -1646,7 +1646,12 @@ XXX end begin opt, cb, val = sw.parse(val, argv) {|*exc| raise(*exc) if eq} + rescue ParseError + raise $!.set_option(arg, arg.length > 2) + else raise InvalidOption, arg if has_arg and !eq and arg == "-#{opt}" + end + begin argv.unshift(opt) if opt and (!rest or (opt = opt.sub(/\A-*/, '-')) != '-') val = cb.call(val) if cb setter.call(sw.switch_name, val) if setter |