From: Bryan Richardson Date: 2008-02-20T13:56:32+09:00 Subject: Re: Need Help With OptionParser ------=_Part_240_27888937.1203483400376 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline Perfect!!! Thanks for the help. On Tue, Feb 19, 2008 at 9:36 PM, Nobuyoshi Nakada wrote: > Hi, > > At Wed, 20 Feb 2008 10:00:17 +0900, > Bryan Richardson wrote in [ruby-talk:291710]: > > I'm wrapping a bunch of scripts with an command-line program, and I'm > > wanting to use OptionParser to grab some of the options for the wrapper > > application. Can anyone tell me if it's possible to rescue all the > invalid > > options for the wrapper application such that I can leave them in ARGV > so > > they're available to my scripts when I load them? > > OptionParser raises an OptionParser::InvalidOption, which has > erred option in args. > > others = [] > ARGV.options do |opt| > opt.on("--foo=BAR") {|foo| puts "foo option #{foo}"} > begin > opt.parse! > rescue OptionParser::InvalidOption => e > others.concat(e.args) > end > end > exec("your command", *ohters) > > -- > Nobu Nakada > > ------=_Part_240_27888937.1203483400376--