Prev: pathname.rb:270: warning: `*' interpreted as argument prefix
Next: Increase significant digits in Float
From: Zhao Yi on 30 Jun 2010 07:27 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. thanks, Zhao Yi -- Posted via http://www.ruby-forum.com/.
From: Robert Klemme on 30 Jun 2010 08:34
2010/6/30 Zhao Yi <youhaodeyi(a)gmail.com>: > 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/ |