From: greg weber Date: 2006-09-11T00:14:57+09:00 Subject: [PATCH] OptionParser < Hash Hi, From the example in the code of optparse.rb, It seems to me that we are making users of optparse go to the extra effor of creating a wrapper class for OptionParser. This is a 5 line patch will allow for the use of OptionParser itself to automatically store values from options. Now options can be built in the following manner: #example.rb -d 5 require 'optparse' opts = OptionParser.new do |o| # Cast 'delay' argument to a Float. o.on("--delay N", Float, "Delay N seconds before executing") {|n| n} end opts.parse!(ARGV) p opts #{:delay=>5.0} By default, there will be a hash key for the long form of the option and its value will be the return of the block. If necessary, this can be avoided by returning nil. This patch is against 1.40.2.12 Include in the patch is an updated full example. I was also wondering if there is any way to specify mutually exclusive or required options with optparse. Greg Weber