Forum: Ruby Check ARGV for option (what parser to use?)

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Boris C. (Guest)
on 2007-07-02 18:37
Dear mailinglist,

Currently I'm eluded by the ARGV parser GetoptLong.
All the example show me the same structure that just itterates through
all the parsed flags and then overwrite a previously set standard value
when a certain case branch gets hit.

Am I completely wrong or is this a horrible way of doing things?

I would like for example to first check if a certain flag is set (--help
for example) before I get to setting and parsing values.

I would think that the parser creates a Hash table and that I could
acces it in this style:

if (opts[:help]) then
   puts "some usage help"
else
   parse all other values
end

Am I off track here?

regards
Boris
Ari B. (Guest)
on 2007-07-02 18:46
(Received via mailing list)
On Jul 2, 2007, at 10:37 AM, Boris Callens wrote:
<snip>

I user CommandLine::OptionParser (gem), but there is also optparse.
You might have better luck with those.

-------------------------------------------|
Nietzsche is my copilot
This topic is locked and can not be replied to.