From: Jan Svitok Date: 2006-11-02T19:32:03+09:00 Subject: Re: Something more compact for getopt On 11/2/06, Maciej Pilichowski wrote: > Hello, > > I use GetoptLong but I miss something much shorter in usage like > GetoptLong in Perl. In Perl I could write > > GetOptions('re_from=s' => \$re_from, 're_to=s' => \$re_to, 'do' => > \$do_do, 'enum' => \$enum, 'from=i' => \$from, 'step=i' => \$step, > 'width=i' => \$width); > > So in one line -- or two -- I set the possible arguments, their > types, assignment to variables and all the if-checking is done for me. > No need to write loop to check all parameters like in Ruby. > Is any package available which do similar thing for Ruby? > > Thanks in advance, have a good day > bye try optparse [1], though not that concise, it's pretty nice and easy to use. You can find pretty smart usage in [2]. look for # default options [1] http://ruby-doc.org/stdlib/libdoc/optparse/rdoc/index.html [2] http://rubyforge.org/cgi-bin/viewvc.cgi/trunk/projects/mongrel_service/bin/mongrel_service?revision=358&root=mongrel