Bryan Richardson
2/20/2008 4:57:00 AM
[Note: parts of this message were removed to make it a legal post.]
Perfect!!! Thanks for the help.
On Tue, Feb 19, 2008 at 9:36 PM, Nobuyoshi Nakada <nobu@ruby-lang.org>
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
>
>