# Check ARGV for option (what parser to use?)

**URL:** <https://www.ruby-forum.com/t/check-argv-for-option-what-parser-to-use/108346>\
**Category:** Ruby\
**Created:** [July 2, 2007, 4:37pm UTC](https://www.ruby-forum.com/t/check-argv-for-option-what-parser-to-use/108346 "2007-07-02T16:37:06Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![boersnoes](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/ecd19e/32.png) [@boersnoes](https://www.ruby-forum.com/u/boersnoes)\
**Post date:** [July 2, 2007, 4:37pm UTC](https://www.ruby-forum.com/t/check-argv-for-option-what-parser-to-use/108346/1 "2007-07-02T16:37:06Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![boersnoes](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/ecd19e/32.png) [@boersnoes](https://www.ruby-forum.com/u/boersnoes)\
**Post date:** [July 2, 2007, 4:46pm UTC](https://www.ruby-forum.com/t/check-argv-for-option-what-parser-to-use/108346/2 "2007-07-02T16:46:00Z")

</div>

On Jul 2, 2007, at 10:37 AM, Boris Callens wrote:

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

-------------------------------------------|  
Nietzsche is my copilot
