From: Robert Klemme Date: 2010-06-30T21:34:21+09:00 Subject: Re: optparser question 2010/6/30 Zhao Yi : > I am using optparser to parse arguments.How can I set a mandatory > option? If user doesn't specify this option, parse() method should throw > an error message. There are no mandatory options - after all, they are _options_. You can only have mandatory arguments to options: http://www.ruby-doc.org/stdlib/libdoc/optparse/rdoc/classes/OptionParser.html You need an extra flag which you set when the option is seen. Then you can throw or do whatever after #parse has finished. Kind regards robert -- remember.guy do |as, often| as.you_can - without end http://blog.rubybestpractices.com/