# Option parse

**URL:** <https://www.ruby-forum.com/t/option-parse/111728>\
**Category:** Ruby\
**Created:** [August 10, 2007, 6:08am UTC](https://www.ruby-forum.com/t/option-parse/111728 "2007-08-10T06:08:43Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![dreamwave](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/7feea3/32.png) [@dreamwave](https://www.ruby-forum.com/u/dreamwave)\
**Post date:** [August 10, 2007, 6:08am UTC](https://www.ruby-forum.com/t/option-parse/111728/1 "2007-08-10T06:08:43Z")

</div>

is there a better, or different way to pipe arguments to a program  
rather than using optparse? or is that the best and fastest way?

---

<div class="post-metadata">

**Author:** ![dreamwave](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/7feea3/32.png) [@dreamwave](https://www.ruby-forum.com/u/dreamwave)\
**Post date:** [August 10, 2007, 8:04am UTC](https://www.ruby-forum.com/t/option-parse/111728/2 "2007-08-10T08:04:14Z")

</div>

Hi,

Jon H. wrote:

> is there a better, or different way to pipe arguments to a program  
> rather than using optparse? or is that the best and fastest way?

Well, there are more possiblilities:

[http://www.ruby-doc.org/stdlib/libdoc/getoptlong/rdoc/index.html](http://www.ruby-doc.org/stdlib/libdoc/getoptlong/rdoc/index.html)

[http://www.ruby-doc.org/stdlib/libdoc/yaml/rdoc/index.html](http://www.ruby-doc.org/stdlib/libdoc/yaml/rdoc/index.html)

But all depends on what is your meaning of “best”. On the question of  
speed, I think this is mainly irrelevant. You only read start up options  
once.

Lutz

---

<div class="post-metadata">

**Author:** ![dreamwave](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/7feea3/32.png) [@dreamwave](https://www.ruby-forum.com/u/dreamwave)\
**Post date:** [August 14, 2007, 11:02pm UTC](https://www.ruby-forum.com/t/option-parse/111728/3 "2007-08-14T23:02:09Z")

</div>

Check out the OptionParser gem. I find it to be simpler than  
optparse, though you may differ in your opinion…

On Aug 10, 2007, at 12:08 AM, Jon H. wrote:

> ## is there a better, or different way to pipe arguments to a program rather than using optparse? or is that the best and fastest way?
> 
> Posted via [http://www.ruby-forum.com/](http://www.ruby-forum.com/).

--------------------------------------------|  
If you’re not living on the edge,  
then you’re just wasting space.

---

<div class="post-metadata">

**Author:** ![dreamwave](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/7feea3/32.png) [@dreamwave](https://www.ruby-forum.com/u/dreamwave)\
**Post date:** [August 17, 2007, 5:24am UTC](https://www.ruby-forum.com/t/option-parse/111728/4 "2007-08-17T05:24:52Z")

</div>

From: ara.t.howard [[mailto:removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)]

# i prefer not to parse options, or at least i’ve written it one final

# time:

…

# with main you can abstract all that repetitive stuff into a few

# declarative statements.

how come i missed this nifty tool? was it because you named it Main,  
ara? 🙂 Nice gem really. thanks for main  
kind regards -botp

---

<div class="post-metadata">

**Author:** ![dreamwave](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/7feea3/32.png) [@dreamwave](https://www.ruby-forum.com/u/dreamwave)\
**Post date:** [August 16, 2007, 6:01pm UTC](https://www.ruby-forum.com/t/option-parse/111728/5 "2007-08-16T18:01:35Z")

</div>

On Aug 9, 2007, at 10:08 PM, Jon H. wrote:

> is there a better, or different way to pipe arguments to a program  
> rather than using optparse? or is that the best and fastest way?

i prefer not to parse options, or at least i’ve written it one final  
time:

[http://codeforpeople.com/lib/ruby/main/main-0.0.2/samples/a.rb](http://codeforpeople.com/lib/ruby/main/main-0.0.2/samples/a.rb)  
[http://codeforpeople.com/lib/ruby/main/main-0.0.2/samples/b.rb](http://codeforpeople.com/lib/ruby/main/main-0.0.2/samples/b.rb)  
[http://codeforpeople.com/lib/ruby/main/main-0.0.2/samples/c.rb](http://codeforpeople.com/lib/ruby/main/main-0.0.2/samples/c.rb)  
[http://codeforpeople.com/lib/ruby/main/main-0.0.2/samples/d.rb](http://codeforpeople.com/lib/ruby/main/main-0.0.2/samples/d.rb)

gem install main

with main you can abstract all that repetitive stuff into a few  
declarative statements.

regards.

a @ [http://drawohara.com/](http://drawohara.com/)
