[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

[ANN] GetOptions 0.1 released

Delaney Parker

12/1/2007 12:05:00 AM


GetOptions - Yet another command line argument parser for Ruby. Inspired
by Perl's Getopt::Long module, the GetOptions module provides a fairly
powerful POSIX-ish option parser that is very easy to learn and use.


http://rubyforge.org/projects/g...


A quick and dirty example...
--
$ cat example.rb
require 'getoptions'

opt = GetOptions.new(%w(help debug! verbose+ prefix:s size=i host=@s))
p opt

--
$ ./example.rb --help
:help: true

$ ./example.rb --debug
:debug: true

$ ./example.rb --no-debug
:debug: false

$ ./example.rb -vvvvv
:verbose: 5

$ ./example.rb -vv --verbose
:verbose: 3

$ ./example.rb --pre
:prefix: nil

$ ./example.rb --pre myprefix
:prefix: "myprefix"

$ ./example.rb --size 5
:size: 5

$ ./example.rb --host foo bar baz
:host: ["foo", "bar", "baz"]


Give it a whirl and let me know what you think.

Enjoy,
Delaney