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/.
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/.
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
2010/6/30 Zhao Yi <youhaodeyi@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.
--
remember.guy do |as, often| as.you_can - without end
http://blog.rubybestpractices.com/