I did some thing trying to reverse engineer the parser, but I don't know if the behavior I have are expected. I got the following error trying to run the ls test (from ApplicationTest) with a GnuParser or a BasicParser.

org.apache.commons.cli.UnrecognizedOptionException: Unrecognized option: --block-size=10
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)
at org.apache.commons.cli.ApplicationTest.doTestLs(ApplicationTest.java:53 )
at org.apache.commons.cli.ApplicationTest.testLsGnu(ApplicationTest.java:6 3)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.ja va:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccesso rImpl.java:25)

Does all parser support long options?
In different ways. BasicParser is a very simple implementation. It doesn't do
any processing of the command line arguments e.g. in this case "--block-size=10"
is treated as one token. Therefore, the parser checks to see if there is an option
names "--block-size=10". Obviously there isn't thus the exception.

GnuParser supports long options but this is the default for Gnu options e.g.
-buildfile, it doesn't make sense to have a '--buildfile' as well.

PosixParser supports long and short options. So in this case "--block-size=10"
is burst into two tokens '--block-size' and '10'. The Option 'block-size' can
be found and the '10' is added as an argument value.

Does this answer your question?

-John K


--
Guillaume Coté
[EMAIL PROTECTED]
Tel. : +33.1.41.45.13.87
Fax. : +33.1.41.45.10.50


--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>


- - - - - - - - - - - - - - - - - - - - - - -
Jakarta Commons CLI
http://jakarta.apache.org/commons/cli


--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to