From: ara.t.howard@... Date: 2006-05-16T23:45:52+09:00 Subject: Re: GetoptLong Accessing the values with out looping On 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, > > Dan nice 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 -- be kind whenever possible... it is always possible. - h.h. the 14th dali lama