commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From LAURENT Frederic SZSIC13 softeam <>
Subject Re: [CLI] UnrecognizedOptionException on simple test
Date Thu, 11 Dec 2003 09:44:36 GMT
LAURENT Frederic SZSIC13 softeam wrote:

> John Keyes wrote:
>> I don't see any obvious errors. Can you write the test
>> in plain java and see if that works.  If not then post
>> the class here and I'll have a look at it.  Sorry for the abruptness 
>> but I am busy at the moment.
> Jython is an interpretor written in java, so the behavior of
> the test will be the same in java...
> That's said, I wrote my test in plain java, and the exception is
> the same...
> java FooMain -url
> usage: java FooMain
>  -url <myurl>   an url
> Exception in thread "main" 
> org.apache.commons.cli.UnrecognizedOptionException: Unrecognized option: -u
>         at org.apache.commons.cli.Parser.processOption(
>         at org.apache.commons.cli.Parser.parse(
>         at org.apache.commons.cli.Parser.parse(
>         at FooMain.main(

I downloaded sources from cvs, and rebuild the jar. But the problem is 
still there.

So I searched deeper in the code...
In the PosixParser class, the flatten method is used to parse the 
command line. In my case (option -url), the token starts with "-" and 
has a length > 2
so we got
// requires bursting
	burstToken(token, stopAtNonOption);

But I don't understand what this method does...
the tokens -u, -r and -l are added in the internal ArrayList (named
tokens) but the -url token isn't  !
So later in the parse method, the hasOption failed, because the -u value
has not been added in the options container (main method of the test)...

Well, I changed the else statement in the flatten method of PosixParser
	burstToken(token, stopAtNonOption);


         //burstToken(token, stopAtNonOption);

the -url is added in the tokens ArrayList and my main program works :

java FooMain -url
usage: java FooMain
  -url <myurl>   an url
url parameter :

Well, what do you think about that ?


XPath free testing software :
Frédéric Laurent           

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message