From: Jeff Dickens Date: 2003-12-01T11:37:08+09:00 Subject: Usage message in optparse.. summarize method? I tried your script, and -h doesn't output anything. I'm using ruby 1.8.0. Looking through the reference docs for optparse, there seems to be a "summarize" method that does what we want. But I can't find diddly for examples of more advanced use of optparse. The stuff at learning-ruby.com and the FIRSTSTEP.ja.html file that comes with the distribution are very basic. Does anyone have more examples of using optparase with the summarize method or any other advanced examples? Thanks. Nathaniel Talbott (nathaniel@NOSPAMtalbott.ws) wrote: >> I've been wanting an easy way to output usage info for my >> programs that use GetoptLong, without having to duplicate all >> the option information; once for the creation of the >> GetoptLong object, and again in a help message. ..snip..>Well, you could try using optparse... > > require 'optparse' > > ARGV.options do |options| > options.on('-d', '--date=DATE', String, 'specify a date'){|v| puts "Date >#{v} passed"} > options.on('-q', '--quiet', 'be verry quiet'){puts "OK, I'm being very, >very, very quiet... can't you tell?"} > options.on_tail('-h', '--help', 'Print this help information'){puts >options; exit} > options.parse! > end > >I believe that's approximately equal to what you posted. I've only just >begun using optparse, but it seems quite powerful and easy to use. > >HTH, > > >Nathaniel > ><:((><