From: nobu.nokada@... Date: 2003-01-21T01:55:47+09:00 Subject: Re: 2 optparse questions Hi, At Mon, 20 Jan 2003 23:34:00 +0900, Han Holl wrote: > Optparse is a quite powerful tool, but there are some issues: Thank you. > 1. It seems not to allow the '-d directory' style of option values. > This is really bad. In the unix world this is almost standard. > Also the Posix recommandation says explicitly that both '-d directroy' > and '-ddirectory' should be accepted. Well, I might misunderstand you? $ ruby -roptparse -e 'ARGV.options{|opt|opt.def_option("-dDIR"){|d|@dir=d};opt.parse!};p self' -- -dhere # $ ruby -roptparse -e 'ARGV.options{|opt|opt.def_option("-dDIR"){|d|@dir=d};opt.parse!};p self' -- -d here # > 2. If you use the recommended form: > ARGV.options do |opts| > .... > opts.parse! > end > then optparse stops command line processing, but continues with > the script. This is also quite wrong. It should _not_ catch the exception > (I can do that myself if I want to). Default beheviour for erroneous > options should be exception. The programmer can put a Usage in the > rescue. parse! outside ARGV.options block. $ ruby -roptparse -e 'ARGV.options{|opt|opt.def_option("-dDIR"){|d|@dir=d}; opt}.parse!;p self' -- -d there # $ ruby -roptparse -e 'ARGV.options{|opt|opt.def_option("-dDIR"){|d|@dir=d}; opt}.parse!;p self' -- -x /usr/lib/ruby/1.8/optparse.rb:1118:in `order!': invalid option: -x (OptionParser::InvalidOption) from /usr/lib/ruby/1.8/optparse.rb:1082:in `catch' from /usr/lib/ruby/1.8/optparse.rb:1082:in `order!' from /usr/lib/ruby/1.8/optparse.rb:1161:in `permute!' from /usr/lib/ruby/1.8/optparse.rb:1187:in `parse!' from -e:1 -- Nobu Nakada