[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Mandatory options with optparse

Imobach González Sosa

8/29/2006 4:06:00 PM

Hi all,

I was playing with optparse (great stuff ;)) and I didn't see how to check if
a mandatory option have been supplied (note that I say mandatory *option*,
not mandatory *argument*).

So, if I got the next chunk of code:

opts = OptionParser.new do |opts|
opts.banner = "My silly example"

opts.on("-m", "--message MESSAGE", "A message to show") do |m|
options.message = m
end
end

I figured out that I'd must check it by my own (if options.message.nil?...),
but I only wanna know if there's a "optparse-way".

Thanks in advance!

--
_o) Imobach González Sosa
//\ email: imobachgs at banot dot net
V_/_ jid: osoh at jabberes dot org
url: http://www.banot....
blog: http://devnull.blogs...

1 Answer

Nobuyoshi Nakada

8/31/2006 2:05:00 AM

0

Hi,

At Wed, 30 Aug 2006 01:06:20 +0900,
Imobach González Sosa wrote in [ruby-talk:211331]:
> I figured out that I'd must check it by my own (if options.message.nil?..),
> but I only wanna know if there's a "optparse-way".

There is no suck way. I had thought about the idea like it
formerly, but concluded that it's easy to read and write in
ruby, rather than in mini-DSL.

--
Nobu Nakada