I have some code that looks like this:
def go!
options = {}
return if not ARGV.options do |opts|
exit = true
opts.on_tail("–help", “show this message”) { |exit| puts opts; }
opts.on(’–logfile=LOGFILE’, String) { |options[:logfile]| }
opts.parse!
!exit
end
orb = CORBA::ORB_init($0, ARGV)
# ...
end
I’d like for optparse to ignore invalid options so that I can pass them
to ORB_init. Is this possible?
Also, I noticed that getoptlong lets me use:
ruby foo.rb --opt arg
but optparse requires:
ruby foo.rb --opt=arg
Is it possible to get optparse to allow the form without ‘=’?
Thanks,
Paul
Hi,
I’d like for optparse to ignore invalid options so that I can pass them
to ORB_init. Is this possible?
OptionParser::InvalidOption has an accessor “args”.
You’ll be possilbe to:
other_options = []
begin
opts.parse!
rescue OptionParser::InvalidOption => e
other_options.concat e.args
end
# ... and
orb = CORBA::ORB_init($0, other_options + ARGV)
Also, I noticed that getoptlong lets me use:
ruby foo.rb --opt arg
but optparse requires:
ruby foo.rb --opt=arg
Is it possible to get optparse to allow the form without ‘=’?
$ ruby -roptparse -e ‘ARGV.options{|opt|opt.on(“–opt=ARG”){|@arg|};opt.parse!};p self,ARGV’ – --opt arg
#<Object:0x402de934 @arg=“arg”>
···
At Sat, 14 Jun 2003 02:48:40 +0900, Paul Brannan wrote:
–
Nobu Nakada