From: Paul Lutus Date: 2006-11-14T09:45:06+09:00 Subject: Re: parsing unknown options Stefano Crocco wrote: > I'm not a ruby expert, so forgive me if the answer to my question is > obvious. This time, the answer really is obvious. > The problem is that, as far as I can tell, OptParse will raise an > exception when it finds an unknown option (i.e as soon as it hits -c in > my example above). Is there a way around this behavior? Or does anybody > know of a better way to approach the whole problem? Sure. Parse the command line yourself. Scan the input arguments, select those that begin with a dash, submit any second character to a case statement. Use the case statement to distribute your actions. You would have to do the latter no matter how you parsed the command line, and the former is a few lines of code. ----------------------------------------- #!/usr/bin/ruby -w ARGV.each do |com| if com.length > 1 && com[0,1] == '-' case com[1,1] when 'a' then puts "Option a" when 'b' then puts "Option b" when 'c' then puts "Option c" when 'd' then puts "Option d" end end end ----------------------------------------- -- Paul Lutus http://www.arachnoid.com