Project

General

Profile

Actions

Bug #8306

closed

Bug In OptionParser accepted parsing

Added by chaye (Roi Illouz) almost 11 years ago. Updated almost 11 years ago.

Status:
Rejected
Assignee:
-
Target version:
-
ruby -v:
ruby 2.0.0p0 (2013-02-24 revision 39474) [x86_64-linux]
[ruby-core:54493]

Description

=begin
program:
require 'optparse'

options = {}
OptionParser.new do |opts|
opts.on("-a", "--a_param A", "A") do |a|
options[:a] = a
end
opts.on("-b", "--b_param B", "B") do |b|
options[:b] = b
end
end.parse!

puts options
puts ARGV

When adding ops with mandatory params running
./example.rb -a -b x
options: {:a=>"-b"}
ARGV: x

Result should not be greedy -a with no param should raise an exception just like C getopts
Using optional params instead of mandatory yields correct results.
=end

Updated by nobu (Nobuyoshi Nakada) almost 11 years ago

  • Description updated (diff)
  • Status changed from Open to Rejected
  • Priority changed from 5 to 3

Use placed argument "--a_param [A]".

Actions

Also available in: Atom PDF

Like0
Like0