[lnkForumImage]
TotalShareware - Download Free Software

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


 

Forums >

comp.lang.ruby

Re: getoption long question

Albert Chou

10/29/2003 8:51:00 PM



On a tangent, for even more flexibility I modified GetoptLong to be able
to take a user-specified array as input rather than always implicitly
processing ARGV (which it defaults to, for backward compatibility). In
order not to change the original code, I used Ruby's ability to open and
modify an existing class....

Al


-----Original Message-----
From: Daniel Carrera [mailto:dcarrera@math.umd.edu]
Sent: Wednesday, October 29, 2003 12:35 PM
To: ruby-talk ML
Subject: Re: getoption long question

> opts =3D GetoptLong.new(_
> =B7=B7=B7[ "--create-test", "-T", GetoptLong::NO_ARGUMENT ],
> )
>=20
> what if I don't actually want short options such as the -T? (running
out
> of suitable letters, or something)
>=20
> How would I use it then?


opts =3D GetoptLong.new(
[ "--create-test", GetoptLong::NO_ARGUMENT ]
)

The short options are optional. GetoptLong is very flexible. You can=20
have as many or as few short and long options as you like.

$ cat test.rb=20
require 'getoptlong'

opts =3D GetoptLong.new(
[ "--create-test", GetoptLong::NO_ARGUMENT ]
)
$ ruby test.rb=20
$

Cheers,
--=20
Daniel Carrera | OpenPGP KeyID: 9AF77A88
PhD grad student. |=20
Mathematics Dept. | "To understand recursion, you must first
UMD, College Park | understand recursion".