Forum: Ruby-core [ruby-trunk - Bug #7498][Open] Optparse does not complete argument when used with :REQUIRED

Posted by Gondolin (Damien Robert) (Guest)
on 2012-12-02 18:23
(Received via mailing list)
Issue #7498 has been reported by Gondolin (Damien Robert).

----------------------------------------
Bug #7498: Optparse does not complete argument when used with :REQUIRED
https://bugs.ruby-lang.org/issues/7498

Author: Gondolin (Damien Robert)
Status: Open
Priority: Normal
Assignee:
Category: lib
Target version:
ruby -v: ruby 1.9.3p327 (2012-11-10 revision 37606) [x86_64-linux]


#!/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.
Posted by Nobuyoshi Nakada (nobu)
on 2012-12-25 21:48
(Received via mailing list)
Issue #7498 has been updated by nobu (Nobuyoshi Nakada).

Status changed from Assigned to Rejected

Option name string has to come first.
Put :REQUIRED after "--bug".
----------------------------------------
Bug #7498: Optparse does not complete argument when used with :REQUIRED
https://bugs.ruby-lang.org/issues/7498#change-35074

Author: Gondolin (Damien Robert)
Status: Rejected
Priority: Normal
Assignee: nobu (Nobuyoshi Nakada)
Category: lib
Target version: 2.0.0
ruby -v: ruby 1.9.3p327 (2012-11-10 revision 37606) [x86_64-linux]


#!/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.
Please log in before posting. Registration is free and takes only a minute.
Existing account (Switch to SSL-encrypted connection)
NEW: Do you have a Google/GoogleMail or Yahoo account? No registration required!
Log in with Google account | Log in with Yahoo account
No account? Register here.