From: Han Holl Date: 2008-10-22T22:28:55+09:00 Subject: Re: [ANN] Trollop 1.10 released ------=_Part_25059_12070732.1224682227890 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline On Wed, Oct 22, 2008 at 3:25 AM, William Morgan < wmorgan-ruby-talk@masanjin.net> wrote: > Trollop version 1.10 has been released! > > http://trollop.rubyforge.org > > ## DESCRIPTION > > Trollop is a commandline option parser for Ruby that just gets out of your > way. One line of code per option is all you need to write. For that, you > get > a nice automatically-generated help page, robust option parsing, command > subcompletion, and sensible defaults for everything you don't specify. > > Hi William, Would you accept the following patch: --- trollop.rb.orig 2008-10-22 15:24:45.000000000 +0200 +++ trollop.rb 2008-10-22 15:22:40.000000000 +0200 @@ -580,6 +580,11 @@ vals = @p.parse args args.clear @p.leftovers.each { |l| args << l } + class << vals + def method_missing(m, *args) + self[m] + end + end vals rescue CommandlineError => e $stderr.puts "Error: #{e.message}." You then can write opt.num_limbs instead of opt[:num_limbs] , which is not only two characters less to type, but also more in line with the way I use OptionParser. Cheers, Han Holl ------=_Part_25059_12070732.1224682227890--