Feature Requests: Browse | Submit New | Admin

[#8184] Access to additional arguments i. e. filenames

Date:
2007-01-26 20:24
Priority:
3
Submitted By:
Jan Friedrich (janfri)
Assigned To:
Nobody (None)
Category:
Interface Improvements (example)
State:
Open
Summary:
Access to additional arguments i. e. filenames

Detailed description
I like choice and think it's The Ruby Way to parsing commandline arguments. :)

But I'm missing a possibility to access to additional arguments, for example:

program -a 1 -b 2 file1 file2 file3

I'm looking for a simple way to get the parameters file1, file2 and file3. That means the rest of arguments wich are
not parsed.

Add A Comment: Notepad

Please login


Followup

Message
Date: 2009-02-19 23:33
Sender: Grant Austin

This feature is now in the github repo. I'll post another comment
when I've updated the gem on rubyforge.

Simply use Choice.args_of(opt). This gives you the arguments
of 'opt'. For example, "-b" returns ["2",
"file1", "file2", "file3"]. Is
this as desired?

I really want to update Choice so that you can specify the number
of arguments that are associated with an option. That's non-trivial
to support the way Choice is built at the moment. I'll get to
it eventually.
Date: 2008-09-08 17:58
Sender: Sentinel K

I added this to my program -- its a work around, and its only
been tested in one situation. Input param is ARGV. I hope Chris
will give us a way within choice.

module Choice
  def get_unparsed_args(args)
    flat=Choice.choices.to_a.flatten
    args.delete_if { |a| a[0].chr == '-' || a[0,1] == '--' ||
flat.include?(a) }
    args
  end
end

Attached Files:

Name Description Download
No Files Currently Attached

Changes:

No Changes Have Been Made to This Item