OptionParser doesn't work like I expect?!

A

Asfand Yar Qazi

Hi,

Observe the following:

ruby -e 'require "optparse"; o = OptionParser.new do |o| o.on("-c=C",
"desc") {|c|} end; o.parse([]); '

(Note the wrapping - it should all be on one line.)

Why doesn't this raise an error? I'm expecting -c to be a compulsory
argument, but OptionParser doesn't seem to mind (when it should, I
thought.)

How do I make OptionParser raise an error if it doesn't receive a '-c'
argument?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,009
Latest member
GidgetGamb

Latest Threads

Top