Project

General

Profile

Feature #8460

PATCH: optparse: add keep_unknown option

Added by felipec (Felipe Contreras) over 4 years ago. Updated about 4 years ago.

Status:
Assigned
Priority:
Normal
Target version:
-
[ruby-core:55195]

Description

Currently people have to do very convoluted tricks, essentially making
it impossible for optparse to keep unknown options.

The safest and cleanest way is to do it in the code itself.

[1] http://www.ruby-forum.com/topic/88081
[2] http://stackoverflow.com/questions/3642331/can-optparse-skip-unknown-options-to-be-processed-later-in-a-ruby-program

0001-optparse-add-keep_unknown-option.patch (2.1 KB) 0001-optparse-add-keep_unknown-option.patch felipec (Felipe Contreras), 05/29/2013 08:39 PM

History

#1 [ruby-core:55246] Updated by zzak (Zachary Scott) over 4 years ago

  • Status changed from Open to Assigned
  • Assignee set to nobu (Nobuyoshi Nakada)

#2 [ruby-core:55417] Updated by drbrain (Eric Hodel) over 4 years ago

I like this patch, I could use this feature in RDoc's option parser which ignores arguments that were valid for previous versions.

#3 [ruby-core:55420] Updated by prijutme4ty (Ilya Vorontsov) over 4 years ago

Can anyone please take a look at a bug http://bugs.ruby-lang.org/issues/7537#change-37695 considering command-line arguments containing negative numbers (which're erroneously treated ass options) and my patch for it.
I'm afraid that keeping unknown options will silently treat negative numbers (not an exception is raised) and possibly lose their ordering. So please before accepting unknown options patch, decide which behavior for such a case is right and make a specification about negative numbers in command line(as an example, they may became non-options and in such a case this proposal will work differently).
In my bug report and a patch I proposed some specs for optparse behavior in this case, but they weren't yet accepted or declined.

#4 [ruby-core:57000] Updated by felipec (Felipe Contreras) about 4 years ago

Any update on this?

Also available in: Atom PDF