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

No members online now.

Forum statistics

Threads
474,432
Messages
2,571,680
Members
48,796
Latest member
Greg L.

Latest Threads

Top