Project

General

Profile

Bug #7498

Optparse does not complete argument when used with :REQUIRED

Added by Damien Robert about 3 years ago. Updated about 3 years ago.

Status:
Rejected
Priority:
Normal
ruby -v:
ruby 1.9.3p327 (2012-11-10 revision 37606) [x86_64-linux]
Backport:
2.0.0: UNKNOWN, 2.1: UNKNOWN, 2.2: UNKNOWN, 2.3: UNKNOWN
[ruby-core:50485]

Description

#!/usr/bin/env ruby
require 'optparse'

OptionParser.new do |opts|
opts.on(:REQUIRED, "--bug", ["foo", "bar"]) do |v|
puts v
end
opts.on(:REQUIRED, "--nobug ARG", ["foo", "bar"]) do |v|
puts v
end
end.parse!

./bug.rb --bug b
b
./bug.rb --nobug b
bar

As you can see, using "--bug" with :REQUIRED but without specifying the obligatory argument name, the argument to "--bug" does not get completed to the value in the array.

History

#1 Updated by Usaku NAKAMURA about 3 years ago

  • Status changed from Open to Assigned
  • Assignee set to Nobuyoshi Nakada
  • Target version set to 2.0.0

#2 [ruby-core:51135] Updated by Nobuyoshi Nakada about 3 years ago

  • Status changed from Assigned to Rejected

Option name string has to come first.
Put :REQUIRED after "--bug".

Also available in: Atom PDF