commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Mark Fortner" <phidia...@gmail.com>
Subject Re: commons-cli 1.1 mutliple arguments
Date Sat, 01 Sep 2007 16:45:05 GMT
I suspect the problem is that you're using -D parameters (which are used to
set java runtime environment variables) rather than your own options.  Also,
I'm not aware of CLI supporting multiple option values in the same option.
It would be better to simply add multiple options for the various parameters
you are trying to capture.

If you must put all of those parameter name/value pairs into a single
option, it might be better to do it like this:

-P value=key,nextvalue=newkey,hello=world

You can then split them using the "," delimiter, and split them again using
the "=" delimiter to get the name/value pairs that you want.

Hope this helps,

Mark

On 9/1/07, Bodo Tasche <bodo@wannawork.de> wrote:
>
> Hi!
>
> At the moment I am trying add commons-cli 1.1 to a small application,
> but I have a small problem with it.
>
> I used the code shown on the example page:
>
> Option property  = OptionBuilder.withArgName( "property=value" )
>                                  .hasArg()
>                                  .withValueSeparator()
>                                  .withDescription( "use value for given
> property" )
>                                  .create( "D" );
>
>
> But when I give the program the following arguments:
>
> java -jar test.jar -Dvalue=key -Dnextvalue=newkey -Dhello=world
>
> I only geht the first value=key pair. Even when using
> getOptionValues("D") .
>
> Any suggestions?
>
> Thanks,
> Bodo
> --
> http://www.tvbrowser.org
> http://www.wannawork.de
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
> For additional commands, e-mail: user-help@commons.apache.org
>
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message