commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Berin Loritsch" <blorit...@apache.org>
Subject [CLI] How does the Option parsing work?
Date Thu, 12 Sep 2002 13:17:02 GMT
I'm trying to reconcile the differences between Excalibur CLI and
Commons
CLI, so I am trying to build the compatibility testcase.  In the
process,
I tried to keep as much of the processing consistent as I could.

The assumptions of the Excalibur CLI processing is that the results are
returned in the order that they are provided on the command line.  This
is a natural assumption.  Now the key difference between the two is that
Excalibur uses an option descriptor CLOptionDescriptor that describes
the
possible options that an application can expect, and the parser returns
the list of CLOptions that were parsed.  Commons lets the application
declare a set of Options and the parser returns a CommandLine which you
can get that same set of Options with values filled in.

That subtle difference really doesn't amount to much in the great scheme
of things.  However, the *order* in which we receive the Options can be
of importance (not often, mostly for testing purposes, but
occasionally).
With Excalibur CLI I *know* that I am going to receive the options in a
list in the order that they were processed.  In Commons CLI I don't know
at all.  I think the options are added to a Set which does not preserve
any ordering information at all.

Part of the issue is that I want to ensure that a particular order of
options doesn't cause a problem (like it did on Excalibur at one point).
When I get the array of Options back from the CommandLine, I'd like to
know what order they are supposed to be in.

When I added my options to the Parser, it was in this order:

opts.addOption( ALL_OPT );
opts.addOption( TAINT_OPT );

The commandline was in this order:

String[] args = new String[] { "-T", "param", "-a" };

Excalibur CLI responds with:

CLOption: -T param
CLOption: -a

Commons CLI responds with:

Option: -a
Option: -T param

I switched the order in which I added the options, and I got the same
results.

Is there any way we can preserve the order in which the options were
processed on the command line?


"They that give up essential liberty to obtain a little temporary safety
 deserve neither liberty nor safety."
                - Benjamin Franklin


--
To unsubscribe, e-mail:   <mailto:commons-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:commons-dev-help@jakarta.apache.org>


Mime
View raw message