Project

General

Profile

Bug #12438

OptParse: Short style switch with range does not work

Added by vo.x (Vit Ondruch) 12 months ago. Updated 11 months ago.

Status:
Closed
Priority:
Normal
Assignee:
-
Target version:
-
ruby -v:
ruby 2.3.1p112 (2016-04-26 revision 54768) [x86_64-linux]
[ruby-core:75773]

Description

This does not seems to be working:

$ irb
irb(main):001:0> require 'optparse'
irb(main):002:0> o = OptionParser.new
irb(main):003:0> o.on('-[a-z]') {}
irb(main):004:0> o.parse('-f')
NoMethodError: undefined method `size' for nil:NilClass
    from /usr/share/ruby/optparse.rb:433:in `block in complete'
    from /usr/share/ruby/optparse.rb:433:in `each'
    from /usr/share/ruby/optparse.rb:433:in `sort_by'
    from /usr/share/ruby/optparse.rb:433:in `complete'
    from /usr/share/ruby/optparse.rb:838:in `complete'
    from /usr/share/ruby/optparse.rb:1694:in `block in visit'
    from /usr/share/ruby/optparse.rb:1693:in `reverse_each'
    from /usr/share/ruby/optparse.rb:1693:in `visit'
    from /usr/share/ruby/optparse.rb:1725:in `block in complete'
    from /usr/share/ruby/optparse.rb:1724:in `catch'
    from /usr/share/ruby/optparse.rb:1724:in `complete'
    from /usr/share/ruby/optparse.rb:1553:in `block in parse_in_order'
    from /usr/share/ruby/optparse.rb:1527:in `catch'
    from /usr/share/ruby/optparse.rb:1527:in `parse_in_order'
    from /usr/share/ruby/optparse.rb:1521:in `order!'
    from /usr/share/ruby/optparse.rb:1613:in `permute!'
    from /usr/share/ruby/optparse.rb:1635:in `parse!'
    from /usr/share/ruby/optparse.rb:1624:in `parse'
    from (irb):4
    from /usr/bin/irb:11:in `<main>'

Although it is not clear from the documentation, I'd expect that this should match every short option, but unfortunately, it does not work at all ...

Associated revisions

Revision 55228
Added by nobu (Nobuyoshi Nakada) 12 months ago

optparse.rb: fix char class option

  • lib/optparse.rb (OptionParser::Completion.candidate): get rid of nil as key names. [Bug #12438]
  • lib/optparse.rb (OptionParser#make_switch): char class option cannot be NoArgument, default to RequiredArgument.

Revision 55228
Added by nobu (Nobuyoshi Nakada) 12 months ago

optparse.rb: fix char class option

  • lib/optparse.rb (OptionParser::Completion.candidate): get rid of nil as key names. [Bug #12438]
  • lib/optparse.rb (OptionParser#make_switch): char class option cannot be NoArgument, default to RequiredArgument.

Revision 55364
Added by usa (Usaku NAKAMURA) 12 months ago

merge revision(s) 55228: [Backport #12438]

* lib/optparse.rb (OptionParser::Completion.candidate): get rid of
  nil as key names.   [Bug #12438]

* lib/optparse.rb (OptionParser#make_switch): char class option
  cannot be NoArgument, default to RequiredArgument.

Revision 55459
Added by nagachika (Tomoyuki Chikanaga) 11 months ago

merge revision(s) 55228: [Backport #12438]

* lib/optparse.rb (OptionParser::Completion.candidate): get rid of
  nil as key names.   [Bug #12438]

* lib/optparse.rb (OptionParser#make_switch): char class option
  cannot be NoArgument, default to RequiredArgument.

History

#1 Updated by nobu (Nobuyoshi Nakada) 12 months ago

  • Status changed from Open to Closed

Applied in changeset r55228.


optparse.rb: fix char class option

  • lib/optparse.rb (OptionParser::Completion.candidate): get rid of nil as key names. [Bug #12438]
  • lib/optparse.rb (OptionParser#make_switch): char class option cannot be NoArgument, default to RequiredArgument.

#2 [ruby-core:75900] Updated by usa (Usaku NAKAMURA) 12 months ago

  • Backport changed from 2.1: UNKNOWN, 2.2: UNKNOWN, 2.3: UNKNOWN to 2.1: WONTFIX, 2.2: REQUIRED, 2.3: REQUIRED

#3 [ruby-core:75934] Updated by usa (Usaku NAKAMURA) 12 months ago

  • Backport changed from 2.1: WONTFIX, 2.2: REQUIRED, 2.3: REQUIRED to 2.1: WONTFIX, 2.2: DONE, 2.3: REQUIRED

ruby_2_2 r55364 merged revision(s) 55228.

#4 [ruby-core:76077] Updated by nagachika (Tomoyuki Chikanaga) 11 months ago

  • Backport changed from 2.1: WONTFIX, 2.2: DONE, 2.3: REQUIRED to 2.1: WONTFIX, 2.2: DONE, 2.3: DONE

ruby_2_3 r55459 merged revision(s) 55228.

Also available in: Atom PDF