From: tamouse mailing lists Date: 2013-04-27T14:04:36+09:00 Subject: Re: Is there an elegant way to turn optparser.on() into a one-liner? On Fri, Apr 26, 2013 at 11:40 PM, larry fast wrote: > I'm looking at my code for optparser and it's ugly. For 90% of my > options all I really want is a one-liner but the standard form for > opts.on() is... > opts.on( '-f', '--file FILE', 'output file' ) do |file| > @params.file = file > end > > Is there any way to clean that down to a one-liner like: > @params.file = opts.on_str( '-f', '--file FILE', 'output file' > ).value > > I've tried adding a new method to optparse, but I can't figure out how > to pass the list-of-args in. Not sure if this will help, but take a look at how methadone wraps up OptionParser?