commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From John Keyes <j...@mac.com>
Subject Re: [CLI] Feature requests and submissions
Date Wed, 31 Jul 2002 22:39:06 GMT
Hi Berin,

I have added an iterator method to CommandLine (not yet
commited) which returns a java.util.Iterator of the Option
keys.

An example of using this would be as follows:

// create options object
Options options = ...;

CommandLineParser parser = CommandLineParserFactory.newParser();
CommandLine line = parser.parse( options, args );

Iterator iter = line.iterator();
while( iter.hasNext() ) {
    String opt = iter.next().toString();
    String value = line.getOptionValue( opt );
    String value = line.getOptionValue( opt, "default value" );
    String[] values = line.getOptionValues( opt );
    Object obj = line.getOptionObject( opt );
}

Is this the solution you require?

Cheers,
-John K

On Wednesday, July 31, 2002, at 01:11 , Berin Loritsch wrote:

> I am in the process of creating an ExcaliburCompatTest.java to add to
> the
> suite of tests for CLI.  The ExcaliburCLICompatTest is the converted
> test suite
> for Excalibur's CLI utility.  In oder to minimize the rework that needs
> to
> be done to it, I have one request.
>
> Please provide a method where I can get an array of the parsed options
> so
> that I can iterate through them and get the arguments.  If this is
> something
> that is easy to do, I will put together a patch and submit it to the
> list.
>
> I personally prefer to process my arguments in this manner because for
> some
> things a switch statement is more readable than if/then, if/then,
> if/then....
>
> If you have already started on this, let me know.  I will send you the
> conversion I have so far for the ExcaliburCLICompatTest object, so you
> can
> see what might need attending to.
>
>
> "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>
>


--
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