Bugs: Browse | Submit New | Admin

[#22654] Command line switches eat the next non-switch argument

Date:
2008-11-01 20:01
Priority:
5
Submitted By:
Grant Austin (gaustin)
Assigned To:
Nobody (None)
Category:
Interface (example)
State:
Open
Summary:
Command line switches eat the next non-switch argument

Detailed description
When a command line option that takes no arguments is followed by an argument that is not an option, the non-option
argument is taken as the value of the first switch.

Take the example of using UNIX's `wc` command to count the lines in some files: wc -l file1 file2 file3. That translates
into something like this:

    Choice.options do
      option :lines do
        short '-l'
        long  '--lines'
      end
    end

    puts Choice.choices.inspect

When run on the command line with "-l" as the argument, the choices hash includes one key `lines` with the
value true. However, if you run it with "-l file1 file2 file3" as the arguments you get a choices hash with
one key "lines" but the value "file1".

One argumentless option followed by another option is fine (both end up true) unless followed by a non-option argument.

Add A Comment: Notepad

Please login


Followup

No Followups Have Been Posted

Attached Files:

Name Description Download
No Files Currently Attached

Changes:

No Changes Have Been Made to This Item