[lnkForumImage]
TotalShareware - Download Free Software

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


 

Forums >

comp.lang.ruby

optparse to include no opt-args, invalid opt,...

Peña, Botp

4/5/2005 6:54:00 AM

Hi,

OptParse is great to use and its opt#on is neatly structured.
I have not perused the internals of optparse and have just taken a look at
the supposedly complete example under optparse.

i have quick qs though:

1. Can optparse capture nil/empty args?

eg.

C:\family\ruby\optparse>op

C:\family\ruby\optparse>

Of course i can capture empty args. What i want is to include the capture in
optparse structure; something like:

....
opts = OptionParser.new do |opts|
opts.banner = "Usage: example.rb [options]"

opts.separator ""
opts.separator "Specific options:"

# just empty, no options/arguments.
opts.Empty_ARG do
# do something here
# <== btw, i'd like to display the banner above here, how?
end
.....


2. Can optparse capture a simple arg?

eg.

C:\family\ruby\optparse>op sampleFile

C:\family\ruby\optparse>

Of course we can capture single/simple arguments but again, what i want is
to include it in optparse structure; something like:

....
# just an argument, no option here.
opts.simple_ARG do |xarg| #pass the arg
# do something here
# maybe i default it to an option like
# -f xarg
end
.....


3. Can optparse capture errors like invalid options or invalid arguments?

eg.

C:\family\ruby\optparse>op -Z nosuchZoption

C:\family\ruby\optparse>op --delay abc

I can capture errors thru rescue but again, what i want is to include it in
optparse structure; something like:

....
opts.Error do |x| # pass the error here
case x
when OptionParser::InvalidOption
#....
when OptionParser::InvalidArgument
#.....
else
end #case
#exit
end #opts
.....


That is all for now.
Thanks to optparse authors/documentor Nobu and Gavin.

thanks and kind regards -botp

btw, s/want/wish/gi. sometimes, my english too harsh.






3 Answers

nobu.nokada

4/5/2005 1:25:00 PM

0

Hi,

At Tue, 5 Apr 2005 15:54:26 +0900,
Peña, Botp wrote in [ruby-talk:136878]:
> 1. Can optparse capture nil/empty args?
> 2. Can optparse capture a simple arg?
> 3. Can optparse capture errors like invalid options or invalid arguments?

No for all, if I get what you mean by "in optparse structure",
correctly. I guess you're thinking of the case of "capturing
in separated files/classes" for instance, no?

Maybe worthful. Let me consider for a while.

--
Nobu Nakada



no_one_cares

7/20/2011 10:25:00 PM

0

On Thu, 7 Jul 2011 15:22:39 -0400, "alphablasphemer"
<alphablasphemer@gmail.com> wrote:

>"Buster Norris" wrote in message
>news:6tv9175ujuevg6sfc2267hacf30osulecn@4ax.com...
>
>alt.politics IP Search Results File: C:\AP_Data\Q_thoovler.txt
>06/27/2011
>
>This search result file generated by DemocRAT Hall Of Shame.Com
>Copyright? 2010-2011 DemocRAT Hall Of Shame.Com
>York
>northwestern.edu=Northwestern University
>
>IP: 67.247.233.244
>Host: cpe-67-247-233-244.buffalo.res.rr.com
>IP: 76.180.160.154
>Host: cpe-76-180-160-154.buffalo.res.rr.com
>
>Thomas H. Hoovler (52)
>222 Lisbon Ave
>Buffalo, NY 14215-1028
>716-867-7031 Cellphone
>
>Posted from:
>The DemocRATs Hall of Shame!
>http://www.democrathallof...
>
>As usual, Buster got it wrong again. Northwestern university is not in
>Buffalo, NY.

He pulls this stuff out of his ass.

Some guy posted something he didn't like here and said he was
new on the group and Buster said "Bullshit" right away.

I replied as if I was him and forgot and the idiot goes
"Aha!" and then posts an IP number to "prove" it... after he accused
the guy of using a proxy so Buster couldn't find him.

He's an idiot.

Ever notice that everything he forges has some kind of gay
vibe to it? That's how Buster rolls...

Funny how he posts stuff calling gays "mutants"... considering
that then he goes on to tell people to blow him constantly, etc. Talks
about "fisting", etc.

Makes ya' wonder what other groups he's on...

ScotchBright Canadian Fat Ugly Lesbo

7/21/2011 2:27:00 AM

0


> [...nothing at all...]

Mind your own business, Canadian lesbo moose cunt!!!!!!!!!!!!!!

HAAAAAAAAAAAAAAAAAAAAAA!!!!!!!!!!!!!!!!!!!!!!!!!!

On Sat, 16 Oct 2010 11:30:22 -0400, Patriot Games
<Patriot@america.com> wrote:
>
>She's so frazzled, confused and desperate all she can do is COPYCAT
>me...
>
>Hahahahahahahahah!!!

From: Scotius <yodasbud@mnsi.net>
Message-ID: <news.mnsi.net>
mnsi.net = Windsor, Ontario, Canada.

----< Update >----------------------------

On Fri, 27 Aug 2010 12:45:38 -0400, Scotius <yodasbud@mnsi.net> wrote:
> Or are you still obsessed with "sticking that question in my
>face"? You like dangling things in front of other mens' faces, don't
>you?
> Don't try it with me jr., I'll cut it off.

I knew you were a woman.

Thanks for PROVING it!

----------------------------------------------
----< Update >----------------------------

On 12 Sep 2010 01:49:43 GMT, Nobody <not@home.anymore> wrote:
>>Buster Norris wrote:
>> From: Scotius <yodasbud@mnsi.net>
>> Message-ID: <news.mnsi.net>
>> mnsi.net = Windsor, Ontario, Canada.
>This is the well known kook that went by the name of Karen Gordon for
>a long time in the can.politics group. They used to call her Kooky
>KKKaren as she is a racist and a bigot. her dislike of any immigrant
>is legendary.
>
>She changes her name like she changes her panties in a lame attempt
>to hide from the bullshit she spews. She is actually a bigger joke
>that those such as Ray Fischer, Siobhan Mederios and Peter Principle
>although many find that hard to believe.
----------------------------------------------

----------------------------------------------
----< Update >----------------------------

On Tue, 05 Oct 2010 21:33:22 -0400, ScotchBright <skooter@mnsi.net>
wrote:
>Re: 'Tard extraordinaire Buster Norris "accuses" me of changing my name.

>From: ScotchBright <skooter@mnsi.net>
>Organization: NewsGuy - Unlimited Usenet $19.95
>NNTP-Posting-Host: -.newsdawg.com
>X-Newsreader: Forte Agent 4.2/32.1118
>
>From: yodasbud@mnsi.net
>Organization: NewsGuy - Unlimited Usenet $19.95
>NNTP-Posting-Host: -.newsdawg.com
>X-Newsreader: Forte Agent 4.2/32.1118

Yep, he did that!

>Duh! I had to because of the spam I got in my e-mail.
>I never said I didn't you imbecile.

"I don't have a new name twit."
Message-ID: <vakna6h9cv855s90ujrov3o0d105adbuhi@4ax.com>

In case you didn't know "ScotchBright" does NOT equal "Scotius."

In case you didn't know "<skooter@mnsi.net> does NOT equal
"yodasbud@mnsi.net"

>You think I changed it because of YOU? Puh-LEASE!

Yep, that's exactly what you did and WHY you did it. You TRIED to hide
"Scrotius" BECAUSE Buster KICKED YOUR ASS and rubbed your ugly
Canadian face in dogshit, repeatedly.

Everybody knows it...

> The phrase "greatly exaggerated sense of self-importance"
>comes to mind...

Except for a couple of FACTS...

See this name "ScotchBright <skooter@mnsi.net>"?

"ScotchBright" can be absolutely anything and is NOT related to your
email in ANY way. Your Agent newsreader doesn't care and neither does
your news service.

And this part "<skooter@mnsi.net>" does NOT have to be real, does NOT
have to be real-sounding, and can be absolutely anything you want to
type in there. Your Agent newsreader doesn't care and neither does
your news service.

And regarding your LIE that you changed your name "because of the spam
I got in my e-mail."

Your email address was FAKE to begin with:

Email Address: yodasbud@mnsi.net
Result: Rejected
Log: Connect:
Get MX for mnsi.net... OK.
Connect to mail.mnsi.net... OK
= 220 mnsi.net SurgeSMTP (Version 3.9g2-2) http://sur...
> EHLO email-verifier.net
= 250-mnsi.net. Hello email-verifier.net (209.160.72.213)
250-AUTH PLAIN LOGIN
250-ETRN
250-STARTTLS
250-X-ID 73757267656d61696c3532303131313031
250-SIZE 51200000
250 HELP
> MAIL FROM: <info@email-verifier.net>
= 250 Command MAIL OK
> RCPT TO: <yodasbud@mnsi.net>
= 550 No such user (yodasbud) -ERR yodasbud@mnsi.net not found
> QUIT

Oops! Caught LYING, again...

Posted from:
The DemocRATs Hall of Shame!
http://www.democrathallof...