You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@commons.apache.org by Mark Fortner <ph...@gmail.com> on 2007/09/01 18:45:05 UTC

Re: commons-cli 1.1 mutliple arguments

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 <bo...@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
>
>

Re: commons-cli 1.1 mutliple arguments

Posted by Bodo Tasche <bo...@wannawork.de>.
sebb schrieb:
>> It would be nice if people dropped their home brewed CLI libraries and
>> made one de facto standard.
> 
> If only there were a single standard command-line syntax that was
> well-defined and documented, but there are at least two slightly
> different ones.

In commons-cli 1.1 you can add your own commandline parser. Doesn't this 
handle the syntax for the command-line?

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


Re: commons-cli 1.1 mutliple arguments

Posted by sebb <se...@gmail.com>.
On 02/09/07, Russel Winder <ru...@russel.org.uk> wrote:
> On Sun, 2007-09-02 at 10:50 +0100, sebb wrote:
> > On 02/09/07, Russel Winder <ru...@russel.org.uk> wrote:
>
> > > Is Avalon CLI the same thing as Commons CLI 2.x ?
> >
> > No - it was originally part of Avalon/Excalibur.
> > As that project was defunct as far as I could tell, I extracted the
> > code to fix if for JMeter.
>
> So you didn't think Commons CLI was usable then :-(

CLI 1.0 was not suitable at the time; it also used a very different
way of defining options. Also used a slightly different command-line
syntax, as far as I could tell.

CLI 2.0 was only just starting.

> I had thought the Avalon CLI and the Commons CLI projects had come
> together to try and create a single CLI project for Apache Commons.  It

There are several different "standard" syntaxes for CLI arguments.

> seems thought hat people are going back to doing their own thing.
>
> I guess there is a lot of dithering going on.  Two aspects:
>
>        1.  Annotations or not.

Requires Java 1.5+ ??

>        2.  Fix Commons CLI or start again.
>
> For Groovy, annotations is not an option in the short term, but is in
> the long term.
>
> It would be nice if people dropped their home brewed CLI libraries and
> made one de facto standard.

If only there were a single standard command-line syntax that was
well-defined and documented, but there are at least two slightly
different ones.

> --
> Russel.
> ====================================================
> Dr Russel Winder                       t: +44 20 7585 2200
> 41 Buckmaster Road               m: +44 7770 465 077
> London SW11 1EN, UK              w: http://www.russel.org.uk/
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
For additional commands, e-mail: user-help@commons.apache.org


Re: commons-cli 1.1 mutliple arguments

Posted by Russel Winder <ru...@russel.org.uk>.
On Sun, 2007-09-02 at 10:50 +0100, sebb wrote:
> On 02/09/07, Russel Winder <ru...@russel.org.uk> wrote:

> > Is Avalon CLI the same thing as Commons CLI 2.x ?
> 
> No - it was originally part of Avalon/Excalibur.
> As that project was defunct as far as I could tell, I extracted the
> code to fix if for JMeter.

So you didn't think Commons CLI was usable then :-(

I had thought the Avalon CLI and the Commons CLI projects had come
together to try and create a single CLI project for Apache Commons.  It
seems thought hat people are going back to doing their own thing.

I guess there is a lot of dithering going on.  Two aspects:

	1.  Annotations or not.
	2.  Fix Commons CLI or start again.

For Groovy, annotations is not an option in the short term, but is in
the long term.

It would be nice if people dropped their home brewed CLI libraries and
made one de facto standard.

-- 
Russel.
====================================================
Dr Russel Winder                       t: +44 20 7585 2200
41 Buckmaster Road               m: +44 7770 465 077
London SW11 1EN, UK              w: http://www.russel.org.uk/

Re: commons-cli 1.1 mutliple arguments

Posted by sebb <se...@gmail.com>.
On 02/09/07, Russel Winder <ru...@russel.org.uk> wrote:
> On Sat, 2007-09-01 at 20:07 +0100, sebb wrote:
> > On 01/09/07, Russel Winder <ru...@russel.org.uk> wrote:
>
> > > The problem is that commands lines with:
> > >
> > >        -D... -D... -D... -J -X... -J -X.... -D....
> > >
> > > are exactly what is needed.  If Commons CLI cannot handle such command
> > > lines (and currently 1.1 cannot) then it is not an alternative.
> >
> > For much the same reasons, I had to abandon converting JMeter from
> > Avalon CLI to use Commons CLI.
> >
> > JMeter uses an updated version of Avalon (which has been contributed
> > to Commons CLI, but not yet released).
>
> Is Avalon CLI the same thing as Commons CLI 2.x ?

No - it was originally part of Avalon/Excalibur.
As that project was defunct as far as I could tell, I extracted the
code to fix if for JMeter.

> --
> Russel.
> ====================================================
> Dr Russel Winder                       t: +44 20 7585 2200
> 41 Buckmaster Road               m: +44 7770 465 077
> London SW11 1EN, UK              w: http://www.russel.org.uk/
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
For additional commands, e-mail: user-help@commons.apache.org


Re: commons-cli 1.1 mutliple arguments

Posted by Russel Winder <ru...@russel.org.uk>.
On Sat, 2007-09-01 at 20:07 +0100, sebb wrote:
> On 01/09/07, Russel Winder <ru...@russel.org.uk> wrote:

> > The problem is that commands lines with:
> >
> >        -D... -D... -D... -J -X... -J -X.... -D....
> >
> > are exactly what is needed.  If Commons CLI cannot handle such command
> > lines (and currently 1.1 cannot) then it is not an alternative.
> 
> For much the same reasons, I had to abandon converting JMeter from
> Avalon CLI to use Commons CLI.
> 
> JMeter uses an updated version of Avalon (which has been contributed
> to Commons CLI, but not yet released).

Is Avalon CLI the same thing as Commons CLI 2.x ?

-- 
Russel.
====================================================
Dr Russel Winder                       t: +44 20 7585 2200
41 Buckmaster Road               m: +44 7770 465 077
London SW11 1EN, UK              w: http://www.russel.org.uk/

Re: commons-cli 1.1 mutliple arguments

Posted by Bodo Tasche <bo...@wannawork.de>.
sebb schrieb:
>> The problem is that commands lines with:
>>
>>        -D... -D... -D... -J -X... -J -X.... -D....
>>
>> are exactly what is needed.  If Commons CLI cannot handle such command
>> lines (and currently 1.1 cannot) then it is not an alternative.
> 
> For much the same reasons, I had to abandon converting JMeter from
> Avalon CLI to use Commons CLI.
> 
> JMeter uses an updated version of Avalon (which has been contributed
> to Commons CLI, but not yet released).
> 

I will remove commons cli, too. This is really a showstopper.
-- 
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


Re: commons-cli 1.1 mutliple arguments

Posted by sebb <se...@gmail.com>.
On 01/09/07, Russel Winder <ru...@russel.org.uk> wrote:
> On Sat, 2007-09-01 at 09:45 -0700, Mark Fortner wrote:
> > 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.
>
> I'm afraid the problem is that Commons CLI just has problems.  1.0 has
> various bugs which Henri and others people have had a good go at fixing.
> Unfortunately, despite all the bug fixes, 1.1 has a couple of
> showstopping bugs which make it unusable -- for the Groovy project at
> least.  I am going to take a look at 2.0 in the next couple of weeks,
> but at the moment -- from the Groovy project perspective -- Commons CLI
> is looking less and less viable.  Many on the team want to ditch using
> it now and move to something home grown or switch to jopt-simple or
> possibly Args4J when we switch to Java 5.
>
> > 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,
>
> The problem is that commands lines with:
>
>        -D... -D... -D... -J -X... -J -X.... -D....
>
> are exactly what is needed.  If Commons CLI cannot handle such command
> lines (and currently 1.1 cannot) then it is not an alternative.

For much the same reasons, I had to abandon converting JMeter from
Avalon CLI to use Commons CLI.

JMeter uses an updated version of Avalon (which has been contributed
to Commons CLI, but not yet released).

> Unfortunately, I don't have the time to be able to wade in and try and
> create a suitable fixing patch.  Commons CLI though needs effort sooner
> rather than later or it will not be a live project.
>
> --
> Russel.
> ====================================================
> Dr Russel Winder                       t: +44 20 7585 2200
> 41 Buckmaster Road               m: +44 7770 465 077
> London SW11 1EN, UK              w: http://www.russel.org.uk/
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
For additional commands, e-mail: user-help@commons.apache.org


Re: commons-cli 1.1 mutliple arguments

Posted by Russel Winder <ru...@russel.org.uk>.
On Sat, 2007-09-01 at 09:45 -0700, Mark Fortner wrote:
> 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.

I'm afraid the problem is that Commons CLI just has problems.  1.0 has
various bugs which Henri and others people have had a good go at fixing.
Unfortunately, despite all the bug fixes, 1.1 has a couple of
showstopping bugs which make it unusable -- for the Groovy project at
least.  I am going to take a look at 2.0 in the next couple of weeks,
but at the moment -- from the Groovy project perspective -- Commons CLI
is looking less and less viable.  Many on the team want to ditch using
it now and move to something home grown or switch to jopt-simple or
possibly Args4J when we switch to Java 5.

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

The problem is that commands lines with:

	-D... -D... -D... -J -X... -J -X.... -D....

are exactly what is needed.  If Commons CLI cannot handle such command
lines (and currently 1.1 cannot) then it is not an alternative.

Unfortunately, I don't have the time to be able to wade in and try and
create a suitable fixing patch.  Commons CLI though needs effort sooner
rather than later or it will not be a live project.

-- 
Russel.
====================================================
Dr Russel Winder                       t: +44 20 7585 2200
41 Buckmaster Road               m: +44 7770 465 077
London SW11 1EN, UK              w: http://www.russel.org.uk/