You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@commons.apache.org by "Edwards, Peter" <Pe...@astrazeneca.com> on 2003/02/10 14:12:06 UTC

[CLI] Problems with Java-like properties

When I use "-Da=1 -Db=2" the method getOptionValues returns an array of [a,
1, b, 2]. Obviously I need to then treat them as pairs. But what if the
command line was used to flag that an option exists but has no value. Then
"-Da -Db=2" returns [a, b, 2] I can no longer treat them as pairs. The user
can solve this by entering "-Da= -Db=2" which returns [a, ,b, 2] but I
wondered if it would be better to return a hashmap of names with a list of
values for that name. There would no longer be any ambiguity for the
developer.

Pete Edwards


Re: [CLI] Problems with Java-like properties

Posted by John Keyes <jb...@mac.com>.
Pete,

I am currently doing some work on a redesign of CLI.  The support for
Java properties will be built into the parser so you could retrieve
them like:

  Properties props = parseResult.getProperties();

So using your example there would be two entries in the Properties
instance.

This will allow people to handle the properties in whatever manner
they wish e.g. add them to an application context, set them as 
system properties, etc.

-John K

On Mon, 2003-02-10 at 13:12, Edwards, Peter wrote:
> When I use "-Da=1 -Db=2" the method getOptionValues returns an array of [a,
> 1, b, 2]. Obviously I need to then treat them as pairs. But what if the
> command line was used to flag that an option exists but has no value. Then
> "-Da -Db=2" returns [a, b, 2] I can no longer treat them as pairs. The user
> can solve this by entering "-Da= -Db=2" which returns [a, ,b, 2] but I
> wondered if it would be better to return a hashmap of names with a list of
> values for that name. There would no longer be any ambiguity for the
> developer.
> 
> Pete Edwards
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: commons-user-help@jakarta.apache.org
-- 
John Keyes <jb...@mac.com>