mirror of
https://github.com/ruby/ruby.git
synced 2025-08-15 13:39:04 +02:00
[ruby/optparse] Also accept '-' as an optional argument (https://github.com/ruby/optparse/pull/35)
f2b8318631
This commit is contained in:
parent
3725454161
commit
419ad1e13e
Notes:
git
2022-07-29 19:10:31 +09:00
2 changed files with 9 additions and 3 deletions
|
@ -765,15 +765,15 @@ class OptionParser
|
|||
end
|
||||
|
||||
#
|
||||
# Switch that takes an argument, which does not begin with '-'.
|
||||
# Switch that takes an argument, which does not begin with '-' or is '-'.
|
||||
#
|
||||
class PlacedArgument < self
|
||||
|
||||
#
|
||||
# Returns nil if argument is not present or begins with '-'.
|
||||
# Returns nil if argument is not present or begins with '-' and is not '-'.
|
||||
#
|
||||
def parse(arg, argv, &error)
|
||||
if !(val = arg) and (argv.empty? or /\A-/ =~ (val = argv[0]))
|
||||
if !(val = arg) and (argv.empty? or /\A-./ =~ (val = argv[0]))
|
||||
return nil, block, nil
|
||||
end
|
||||
opt = (val = parse_arg(val, &error))[1]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue