diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2005-09-26 12:44:47 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2005-09-26 12:44:47 +0000 |
commit | 7aefa8e580f06ff869411092e38b7a18ba44240d (patch) | |
tree | 5ff1b02da7cdbd14228a9a381384e62f8d196d49 /lib | |
parent | 1a6ce22dfad999cd1ad92fc87ba8ec3a52ca4340 (diff) | |
download | ruby-7aefa8e580f06ff869411092e38b7a18ba44240d.tar.gz |
*** empty log message ***
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@9316 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib')
-rw-r--r-- | lib/optparse.rb | 24 |
1 files changed, 14 insertions, 10 deletions
diff --git a/lib/optparse.rb b/lib/optparse.rb index 7135c79b34..f1f207327d 100644 --- a/lib/optparse.rb +++ b/lib/optparse.rb @@ -453,15 +453,12 @@ class OptionParser # # Raises an exception if argument is not present. # - def parse(arg, argv, &error) - opt = (val = parse_arg(val, &error))[1] - val = conv_arg(*val) - if opt and !arg - argv.shift - else - val[0] = nil + def parse(arg, argv) + unless arg + raise MissingArgument if argv.empty? + arg = argv.shift end - val + conv_arg(*parse_arg(arg) {|*exc| raise(*exc)}) end end @@ -484,7 +481,7 @@ class OptionParser # # Switch that takes an argument, which does not begin with '-'. # - class PlacedArgument < RequiredArgument + class PlacedArgument < self # # Returns nil if argument is not present or begins with '-'. # @@ -492,7 +489,14 @@ class OptionParser if !(val = arg) and (argv.empty? or /\A-/ =~ (val = argv[0])) return nil, block, nil end - super + opt = (val = parse_arg(val, &error))[1] + val = conv_arg(*val) + if opt and !arg + argv.shift + else + val[0] = nil + end + val end end end |