commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From John Keyes <j...@mac.com>
Subject Re: [CLI] UnrecognizedOptionException on simple test
Date Wed, 10 Dec 2003 17:05:05 GMT
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.

-John K
 
On Wednesday, December 10, 2003, at 04:15PM, LAURENT Frederic SZSIC13 softeam <frederic.laurent@interieur.gouv.fr>
wrote:

>Hello
>
>I am trying to make a simple test working with CLI, but without
>success :(
>Well, I add an Option (ie "url"), and when I test this command
>line
>
>java fooMain -url http://foo.com
>
>an exception is thrown
>
>org.apache.commons.cli.UnrecognizedOptionException: Unrecognized option:
>-u
>
>Here some Jython code of what I am doing
>
> >>> options = Options()
> >>> OptionBuilder.withArgName("url")
>org.apache.commons.cli.OptionBuilder@1795327
> >>> OptionBuilder.hasArg()
>org.apache.commons.cli.OptionBuilder@1795327
> >>> OptionBuilder.withDescription("an url")
>org.apache.commons.cli.OptionBuilder@1795327
> >>> url = OptionBuilder.create("url")
> >>> options.addOption(url)
>[ Options: [ short {-url=[ option: url  :: an url ]} ] [ long {} ]
>
> >>> test="-url http://foo.com"
> >>> parser=PosixParser()
> >>> line = parser.parse(options,[String(test)])
>
>Traceback (innermost last):
>   File "<console>", line 1, in ?
>org.apache.commons.cli.UnrecognizedOptionException: Unrecognized option: -u
>         at org.apache.commons.cli.Parser.processOption(Parser.java:253)
>         at org.apache.commons.cli.Parser.parse(Parser.java:170)
>         at org.apache.commons.cli.Parser.parse(Parser.java:114)
>...
>
>
>then If I remove the '-', no exception is thrown but the result is
>null (None in Jython)
>
>
> >>>>>> test="url http://foo.com"
> >>>>>> line = parser.parse(options,[String(test)])
> >>>>>> print line.getOptionValue("url")
>None
>
>I have downloaded the zip file available on the jakarta website (1.0),
>and so I do not get sources from cvs.
>
>any idea ?
>
>thanks
>
>
>-- 
>XPath free testing software :  http://lantern.sourceforge.net
>Fr�d�ric Laurent                     http://www.opikanoba.org
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
>For additional commands, e-mail: commons-user-help@jakarta.apache.org
>
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org


Mime
View raw message