Just ARGV, I'm afraid. I suppose you could push args onto ARGV directly
as a workaround.
May I ask when you would want to parse an arbitrary array? I'm curious.
Oh, and when I said, "Yes, it sucks", I was referring to getoptlong in
the stdlib, not your code in particular. Just thought I should clarify
that.
Regards,
Dan
This communication is the property of Qwest and may contain confidential or
privileged information. Unauthorized use of this communication is strictly
prohibited and may be unlawful. If you have received this communication
in error, please immediately notify the sender by reply e-mail and destroy
all copies of the communication and any attachments.
路路路
-----Original Message-----
From: ara.t.howard@noaa.gov [mailto:ara.t.howard@noaa.gov]
Sent: Tuesday, May 16, 2006 8:46 AM
To: ruby-talk ML
Subject: Re: GetoptLong Accessing the values with out loopingOn Tue, 16 May 2006, Berger, Daniel wrote:
>> -----Original Message-----
>> From: Paul D. Kraus [mailto:paul.kraus@gmail.com]
>> Sent: Tuesday, May 16, 2006 8:13 AM
>> To: ruby-talk ML
>> Subject: Re: GetoptLong Accessing the values with out looping
>>
>>
>>>
>>> opts = {} and gl.each{|k,v| opts[k.delete('-')] = v}
>>>
>> Makes perfect sense in this example you are still looping
through the
>> options. All though this is better on the eyes.
>>
>> I was hoping that the instance of getoptlong had some kind
of method
>> to get the value of one of the command line options.
>>
>> Paul
>
> Yes, it sucks. That's why I wrote the 'getopt' package.
>
> gem install getopt
>
> require 'getopt/long'
> include Getopt
>
> opts = Getopt::Long.new(['-d', '--date', REQUIRED])
>
> if opts['d']
> # ...
> end
>
> Regards,
>
> Dannice dan. i've been using optparse for all my stuff but it's
usage is a bit obtuse. perhaps i'll switch... does it
support parsing arbitrary arrays or only ARGV?regards.
-a