Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   Ruby (http://www.velocityreviews.com/forums/f66-ruby.html)
-   -   Mandatory options with optparse (http://www.velocityreviews.com/forums/t832903-mandatory-options-with-optparse.html)

Imobach González Sosa 08-29-2006 04:06 PM

Mandatory options with optparse
 
Hi all,

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

So, if I got the next chunk of code:

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

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

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

Thanks in advance!

=2D-=20
_o) Imobach Gonz=E1lez Sosa
//\ email: imobachgs at banot dot net
V_/_ jid: osoh at jabberes dot org
url: http://www.banot.net/~osoh/
blog: http://devnull.blogs.banot.net


nobu@ruby-lang.org 08-31-2006 02:04 AM

Re: Mandatory options with optparse
 
Hi,

At Wed, 30 Aug 2006 01:06:20 +0900,
Imobach Gonz=E1lez Sosa wrote in [ruby-talk:211331]:
> I figured out that I'd must check it by my own (if options.message.nil?..=

),=20
> 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.

--=20
Nobu Nakada



All times are GMT. The time now is 12:32 AM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.