You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@commons.apache.org by Roland Roberts <ro...@astrofoto.org> on 2008/05/20 23:12:18 UTC

[cli2] Negative number arguments seen as options

I just discovered that an option that takes an argument can't provide a 
negative value, --value -2 is seen as option "value" followed by option 
"2".  This is true even if I use NumberValidator; I tried that thinking 
it might provide a hint to the parser.

259 roland> cd commons-cli-2.0
260 roland> svn up
At revision 658435.


roland

-- 
		       PGP Key ID: 66 BC 3B CD
Roland B. Roberts, PhD                             RL Enterprises
roland@rlenter.com                            6818 Madeline Court
roland@astrofoto.org                           Brooklyn, NY 11220


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


Re: [cli2] Negative number arguments seen as options

Posted by Henri Yandell <fl...@gmail.com>.
Release it? :)

CLI1 and CLI2 are already basically different parsers and living in
the same site. If you want the Avalon one out there, go for it and I
don't see any reason why it can't be on the same site.

Hen

On Wed, May 21, 2008 at 3:11 AM, sebb <se...@gmail.com> wrote:
> Dare I say it:
>
> this used to be a problem for the Avalon CLI package used by JMeter,
> but it was fixed a long time ago. [The parser is very different so I
> doubt the fix would apply to CLI2]
>
> The Avalon CLI was added to SVN some while ago; it would be nice if it
> could be released ;-)
>
> On 21/05/2008, James Carman <ja...@carmanconsulting.com> wrote:
>> FYI:
>>
>>  https://issues.apache.org/jira/browse/CLI-150
>>
>>
>>
>>  On Tue, May 20, 2008 at 11:22 PM, James Carman
>>  <ja...@carmanconsulting.com> wrote:
>>  > What type of parser are you using?
>>  >
>>  > On Tue, May 20, 2008 at 10:51 PM, Roland Roberts <ro...@astrofoto.org> wrote:
>>  >> James Carman wrote:
>>  >>>
>>  >>> Why the leading space inside the quote?
>>  >>>
>>  >>
>>  >> The first part of the answer was and is NO.  Quoting does not help.  Single
>>  >> quotes, double quotes, backslashes, nada, nothing, zip, zilch, no effect.
>>  >>
>>  >> The second part of the answer was IF I DO and put the quote at the
>>  >> beginning, then the parser does not consider it to be an option, but it
>>  >> fails to convert to an integer.
>>  >>
>>  >> Quoting doesn't help.
>>  >>
>>  >> roland
>>  >>>
>>  >>> On Tue, May 20, 2008 at 5:51 PM, Roland Roberts <ro...@astrofoto.org>
>>  >>> wrote:
>>  >>>
>>  >>>>
>>  >>>> James Carman wrote:
>>  >>>>
>>  >>>>>
>>  >>>>> Can you quote it?
>>  >>>>>
>>  >>>>
>>  >>>> No.  If I do
>>  >>>>
>>  >>>> foo --value " -2"
>>  >>>>
>>  >>>> it "works" but then 'new Integer(" -2") throws NumberException; it
>>  >>>> doesn't
>>  >>>> like leading spaces.
>>  >>
>>  >> --
>>  >>                       PGP Key ID: 66 BC 3B CD
>>  >> Roland B. Roberts, PhD                             RL Enterprises
>>  >> roland@rlenter.com                            6818 Madeline Court
>>  >> roland@astrofoto.org                           Brooklyn, NY 11220
>>  >>
>>  >>
>>  >> ---------------------------------------------------------------------
>>  >> To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
>>  >> For additional commands, e-mail: user-help@commons.apache.org
>>  >>
>>  >>
>>  >
>>
>>  ---------------------------------------------------------------------
>>  To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
>>  For additional commands, e-mail: user-help@commons.apache.org
>>
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
> For additional commands, e-mail: user-help@commons.apache.org
>
>

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


Re: [cli2] Negative number arguments seen as options

Posted by sebb <se...@gmail.com>.
On 29/05/2008, Emmanuel Bourg <eb...@apache.org> wrote:
> sebb a écrit :
>
>
> > JMeter originally used the CLI code from Excalibur/Avalon, but the
> > project appeared defunct so when some bugs needed fixing the CLI code
> > was extracted, copied to JMeter and fixed.
> >
> > The Avalon CLI code in Commons is a copy of the JMeter version.
> >
> > Although Commons CLI is partly derived from Avalon, the interface is
> > very different.
> >
>
>  Do you know what features or bug fixes implemented in Avalon/JMeter CLI are
> missing from Commons CLI1/CLI2 ?
>

I never used CLI1/CLI2.

However, the fixes needed to the original Excalibur/Avalon code include:
* Fix bug where second arg could not contain "-"
* Fix -D arg1=arg2 parsing bug
* allow arguments with leading -
* Handle missing second argument where next arg is an option
* sorted 2-arg options with leading - in value
* Fix CLI long optional argument to require "=" (as for short options)

The original code was added to JMeter in r325134; the last fix was in r571988.

HTH.

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

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


Re: [cli2] Negative number arguments seen as options

Posted by Emmanuel Bourg <eb...@apache.org>.
sebb a écrit :

> JMeter originally used the CLI code from Excalibur/Avalon, but the
> project appeared defunct so when some bugs needed fixing the CLI code
> was extracted, copied to JMeter and fixed.
> 
> The Avalon CLI code in Commons is a copy of the JMeter version.
> 
> Although Commons CLI is partly derived from Avalon, the interface is
> very different.

Do you know what features or bug fixes implemented in Avalon/JMeter CLI 
are missing from Commons CLI1/CLI2 ?

Emmanuel Bourg

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


Re: [cli] Avalon CLI vs Commons CLI 1.x

Posted by Emmanuel Bourg <eb...@apache.org>.
Jörg Schaible a écrit :

> Hmmm. I always thought that using the long option the '=' is mandatory while
> for a short option space is optional. 

I checked the documentation for getopt [1], the '=' sign after a long 
option is required only if the argument is optional. Same thing for the 
short options, if the argument is optional it must be grouped with the 
option (-O1 and not -O 1).

So Avalon CLI is right. The catch now if we implement this is to decide 
how multiple optional arguments are handled. I guess this would make the 
value separator mandatory:

--foo=a,b,c

or

-fa,b,c

Emmanuel Bourg


[1] http://www.urbanophile.com/arenn/hacking/getopt/gnu.getopt.Getopt.html

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


Re: [cli] Avalon CLI vs Commons CLI 1.x

Posted by Jörg Schaible <jo...@gmx.de>.
Emmanuel Bourg wrote:

> Emmanuel Bourg a écrit :
> 
>> I'm going to convert the Avalon CLI test case to the Commons CLI API to
>> see what features are missing. I'll see if these features can be
>> implemented in CLI. So maybe we'll have a "common" API at last.
> 
> I completed the conversion of the Avalon CLI tests to the Commons CLI
> API to compare the behavior of the 2 parsers. There were 36 test
> methods, 3 couldn't be converted due to a missing feature in Commons
> CLI, 4 methods fail due to a different behavior, and the rest just works.
> 
> Here are the differences I noticed:
> 
> 1. When 2 exclusive options of a group are in the same command line,
> Commons CLI throws an exception but Avalon CLI doesn't, it exposes an
> error message and the result of the parsing is available. With Commons
> CLI the exception prevents from accessing the result of the parsing.
> 
> 
> 2. Avalon CLI requires that optional arguments have an '=' separator.
> "--foo=bar" is ok but "--foo bar" isn't. I haven't checked but I guess
> it's the same with the short options (ie "-O1" vs "-O 1").
> 
> 
> 3. The PosixParser doesn't stop the parsing on the "--" token if the
> option preceding the token accepts an arguments, the token is used as an
> argument. The Avalon CLI parser and the GnuParser aren't affected by
> this issue.
> 
> 
> 4. There is no equivalent for the ParserControl interface in Commons
> CLI. It's used to interrupt the parsing on a specific option, or after a
> sequence of events.
> 
> 
> 5. Missing arguments are initialized to an empty string in Avalon CLI.
> For example with these options:
> 
>      OptionBuilder.hasArgs(2).withValueSeparator().create('D');
>      OptionBuilder.create('c')
> 
> and this command line:
> 
>      -Dfoo -c
> 
> Avalon CLI assigns 2 values to the -D option, "foo" and "", but Commons
> CLI returns only one value.
> 
> 
> 
> My quick analysis of these differences:
> 
> 1. Avalon CLI warns and Commons CLI fails, I don't know if this is
> useful but we may probably add a setting in OptionGroup to ignore the
> error and continue the parsing.
> 
> 2. I guess this restriction solves some ambiguous cases but it's also
> confusing for the end user, if he omits the '=' separator he may not
> understand why the value is not assigned to the option. I'm not sure
> it's worth implementing in Commons CLI, maybe as a parser setting or as
> an additional parser.

Hmmm. I always thought that using the long option the '=' is mandatory while
for a short option space is optional. See extract from "man diff" of GNU
diffutils:

========== %< ==============
      -I RE  --ignore-matching-lines=RE
              Ignore changes whose lines all match RE.

       --strip-trailing-cr
              Strip trailing carriage return on input.

       -a  --text
              Treat all files as text.

       -c  -C NUM  --context[=NUM]
              Output NUM (default 3) lines of copied context.

       -u  -U NUM  --unified[=NUM]
              Output NUM (default 3) lines of unified context.

       --label LABEL
              Use LABEL instead of file name.

       -p  --show-c-function
              Show which C function each change is in.

       -F RE  --show-function-line=RE
========== %< ==============

> 3. PosixParser should be fixed
> 
> 4. I ignore the use cases for this, I'll check the JMeter code to see if
> it's actually used. If this is proved useful this may be implemented in
> Commons CLI, but not before CLI 1.3.
> 
> 5. Minor difference, can be easily worked around by an application
> migrating from Avalon CLI to Commons CLI

- Jörg


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


Re: [cli2] Negative number arguments seen as options

Posted by Rahul Akolkar <ra...@gmail.com>.
On 5/30/08, Emmanuel Bourg <eb...@apache.org> wrote:
> sebb a écrit :
>
>
> > Neither, as the CLI1 and CLI2 have a different API.
> >
> > However, if the Avalon CLI were released, then JMeter could depend on
> > it, and drop its own copy of the code.
> >
>
>  I'm going to convert the Avalon CLI test case to the Commons CLI API to see
> what features are missing. I'll see if these features can be implemented in
> CLI. So maybe we'll have a "common" API at last.
>
<snip/>

Now that'd be cool :-)

-Rahul

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


Re: [cli2] Negative number arguments seen as options

Posted by Torsten Curdt <tc...@apache.org>.
On May 31, 2008, at 03:27, sebb wrote:

> On 31/05/2008, Niall Pemberton <ni...@gmail.com> wrote:
>> On Fri, May 30, 2008 at 8:12 PM, Emmanuel Bourg <eb...@apache.org>  
>> wrote:
>>> Niall Pemberton a écrit :
>>>>
>>>> How can Avalon CLI be released - that projects closed?
>>>
>>> The Avalon CLI code was imported in a branch of Commons CLI:
>>>
>>> https://svn.apache.org/repos/asf/commons/proper/cli/branches/avalon-implementation/
>>
>>
>> Ah OK - but were really not going to release that -would seem crazy  
>> to
>> potentially have three different flavours out there to support (CLI1,
>> CLI2, CLI-avalaon).
>>
>
> The original Excalibur Avalon CLI may be used by projects other than
> JMeter; if so, then it would be useful for them to have access to an
> updated bug fix version that does not require a major rewrite.
>
> The main motivation for making the Avalon version available was that
> at the time the other CLI versions were very far from being ready for
> use, whereas Avalon was working fine with the fixes applied in JMeter.
>
> Unfortunately nothing happened to it - or indeed the other CLI
> implementations - until recently so it was not as useful as I'd hoped.
>
> I think it has quite an easy API to use compared with CLI1.
> I don't know what the CLI2 API is like.
>
> But if no-one wants to use it - that's fine by me.
> JMeter can continue using its own copy.

My 2 cents here:

I wouldn't say "no-one wants it". I have always been amazed by  
Avalon's code quality. I have hit the wall several times with CLI1 and  
CLI2 was not yet mature enough. But since I don't see much movement in  
this area I would be OK to accept a CLI avalon at least into the  
commons sandbox and go from there.

It's kind of sad: the APIs are not big. With the time and energy we  
have already put into the re-occurring threads about CLI we probably  
could have already fixed the situation.

cheers
--
Torsten


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


Re: [cli2] Negative number arguments seen as options

Posted by sebb <se...@gmail.com>.
On 31/05/2008, Niall Pemberton <ni...@gmail.com> wrote:
> On Fri, May 30, 2008 at 8:12 PM, Emmanuel Bourg <eb...@apache.org> wrote:
>  > Niall Pemberton a écrit :
>  >>
>  >> How can Avalon CLI be released - that projects closed?
>  >
>  > The Avalon CLI code was imported in a branch of Commons CLI:
>  >
>  > https://svn.apache.org/repos/asf/commons/proper/cli/branches/avalon-implementation/
>
>
> Ah OK - but were really not going to release that -would seem crazy to
>  potentially have three different flavours out there to support (CLI1,
>  CLI2, CLI-avalaon).
>

The original Excalibur Avalon CLI may be used by projects other than
JMeter; if so, then it would be useful for them to have access to an
updated bug fix version that does not require a major rewrite.

The main motivation for making the Avalon version available was that
at the time the other CLI versions were very far from being ready for
use, whereas Avalon was working fine with the fixes applied in JMeter.

Unfortunately nothing happened to it - or indeed the other CLI
implementations - until recently so it was not as useful as I'd hoped.

I think it has quite an easy API to use compared with CLI1.
I don't know what the CLI2 API is like.

But if no-one wants to use it - that's fine by me.
JMeter can continue using its own copy.

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

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


Re: [cli2] Negative number arguments seen as options

Posted by Niall Pemberton <ni...@gmail.com>.
On Fri, May 30, 2008 at 8:12 PM, Emmanuel Bourg <eb...@apache.org> wrote:
> Niall Pemberton a écrit :
>>
>> How can Avalon CLI be released - that projects closed?
>
> The Avalon CLI code was imported in a branch of Commons CLI:
>
> https://svn.apache.org/repos/asf/commons/proper/cli/branches/avalon-implementation/

Ah OK - but were really not going to release that -would seem crazy to
potentially have three different flavours out there to support (CLI1,
CLI2, CLI-avalaon).

Niall

> Emmanuel Bourg

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


Re: [cli2] Negative number arguments seen as options

Posted by Emmanuel Bourg <eb...@apache.org>.
Niall Pemberton a écrit :
> How can Avalon CLI be released - that projects closed?

The Avalon CLI code was imported in a branch of Commons CLI:

https://svn.apache.org/repos/asf/commons/proper/cli/branches/avalon-implementation/

Emmanuel Bourg

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


Re: [cli2] Negative number arguments seen as options

Posted by Niall Pemberton <ni...@gmail.com>.
On Fri, May 30, 2008 at 8:01 PM, sebb <se...@gmail.com> wrote:
> On 30/05/2008, Russel Winder <ru...@concertant.com> wrote:
>> On Thu, 2008-05-29 at 16:40 +0100, sebb wrote:
>>
>>  > JMeter originally used the CLI code from Excalibur/Avalon, but the
>>  > project appeared defunct so when some bugs needed fixing the CLI code
>>  > was extracted, copied to JMeter and fixed.
>>  >
>>  > The Avalon CLI code in Commons is a copy of the JMeter version.
>>  >
>>  > Although Commons CLI is partly derived from Avalon, the interface is
>>  > very different.
>>
>>
>> I guess this raises a critical question:
>
> I don't see it as critical myself ...
>
>>  Will JMeter remove its fork of
>>  Commons CLI, put the fixes into Commons CLI 1.2 and then depend on
>>  Commons CLI 1.2 -- or alternatively remove the Commons CLI 1.x fork and
>>  depend on Commons CLI 2.0-SNAPSHOT?
>
> Neither, as the CLI1 and CLI2 have a different API.
>
> However, if the Avalon CLI were released, then JMeter could depend on

How can Avalon CLI be released - that projects closed?

http://avalon.apache.org/closed.html

Niall

> it, and drop its own copy of the code.

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


Re: [cli2] Negative number arguments seen as options

Posted by Emmanuel Bourg <eb...@apache.org>.
sebb a écrit :

> What do you mean by that?
> Do you mean that you won't support the Avalon API?
> If so, then I don't see the point in looking at Avalon at all.

I would not support the Avalon API, that would be absurd to release a 
"Commons CLI" component with 2 APIs, but I would support its features if 
the projects currently using it are interested in switching their API.

Emmanuel Bourg


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


Re: [cli2] Negative number arguments seen as options

Posted by sebb <se...@gmail.com>.
On 31/05/2008, Emmanuel Bourg <eb...@apache.org> wrote:
> sebb a écrit :
>
>
> > The same as what?
> >
> > The CLI and Avalon APIs are different, so the usage cannot be the same for
> both.
> >
>
>  The API are differents, but the features supported are almost identical.

Yes, but it's the API that is important to existing projects that use the code.

> CLI 1 has 3 parsers: BasicParser, GnuParser and PosixParser. If we can't
> improve one of these parsers without maintaining the backward compatibility,
> we may add an AvalonParser supporting the same features as the current
> Avalon CLI.

> But we will not reuse the code & architecture from Avalon/JMeter.

What do you mean by that?
Do you mean that you won't support the Avalon API?
If so, then I don't see the point in looking at Avalon at all.

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

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


[cli] Avalon CLI vs Commons CLI 1.x

Posted by Emmanuel Bourg <eb...@apache.org>.
Emmanuel Bourg a écrit :

> I'm going to convert the Avalon CLI test case to the Commons CLI API to 
> see what features are missing. I'll see if these features can be 
> implemented in CLI. So maybe we'll have a "common" API at last.

I completed the conversion of the Avalon CLI tests to the Commons CLI 
API to compare the behavior of the 2 parsers. There were 36 test 
methods, 3 couldn't be converted due to a missing feature in Commons 
CLI, 4 methods fail due to a different behavior, and the rest just works.

Here are the differences I noticed:

1. When 2 exclusive options of a group are in the same command line, 
Commons CLI throws an exception but Avalon CLI doesn't, it exposes an 
error message and the result of the parsing is available. With Commons 
CLI the exception prevents from accessing the result of the parsing.


2. Avalon CLI requires that optional arguments have an '=' separator. 
"--foo=bar" is ok but "--foo bar" isn't. I haven't checked but I guess 
it's the same with the short options (ie "-O1" vs "-O 1").


3. The PosixParser doesn't stop the parsing on the "--" token if the 
option preceding the token accepts an arguments, the token is used as an 
argument. The Avalon CLI parser and the GnuParser aren't affected by 
this issue.


4. There is no equivalent for the ParserControl interface in Commons 
CLI. It's used to interrupt the parsing on a specific option, or after a 
sequence of events.


5. Missing arguments are initialized to an empty string in Avalon CLI. 
For example with these options:

     OptionBuilder.hasArgs(2).withValueSeparator().create('D');
     OptionBuilder.create('c')

and this command line:

     -Dfoo -c

Avalon CLI assigns 2 values to the -D option, "foo" and "", but Commons 
CLI returns only one value.



My quick analysis of these differences:

1. Avalon CLI warns and Commons CLI fails, I don't know if this is 
useful but we may probably add a setting in OptionGroup to ignore the 
error and continue the parsing.

2. I guess this restriction solves some ambiguous cases but it's also 
confusing for the end user, if he omits the '=' separator he may not 
understand why the value is not assigned to the option. I'm not sure 
it's worth implementing in Commons CLI, maybe as a parser setting or as 
an additional parser.

3. PosixParser should be fixed

4. I ignore the use cases for this, I'll check the JMeter code to see if 
it's actually used. If this is proved useful this may be implemented in 
Commons CLI, but not before CLI 1.3.

5. Minor difference, can be easily worked around by an application 
migrating from Avalon CLI to Commons CLI


Emmanuel Bourg

Re: [cli2] Negative number arguments seen as options

Posted by Emmanuel Bourg <eb...@apache.org>.
sebb a écrit :

> The same as what?
> 
> The CLI and Avalon APIs are different, so the usage cannot be the same for both.

The API are differents, but the features supported are almost identical. 
CLI 1 has 3 parsers: BasicParser, GnuParser and PosixParser. If we can't 
improve one of these parsers without maintaining the backward 
compatibility, we may add an AvalonParser supporting the same features 
as the current Avalon CLI. But we will not reuse the code & architecture 
from Avalon/JMeter.

Emmanuel Bourg

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


Re: [cli2] Negative number arguments seen as options

Posted by sebb <se...@gmail.com>.
On 31/05/2008, Emmanuel Bourg <eb...@apache.org> wrote:
> sebb a écrit :
>
>
> > But can this be done without breaking existing applications?
> >
>
>  I think so. If these changes break the current spec we can still implement
> a new parser.
>
>
> > Nor can one change the parser unless it maintains the same behaviour.
> >
> > Unless the Avalon parser spec. agrees with the CLI1 spec, one will
> > just end up with two separate CLI implementations in one jar.
> >
>
>  You may have several parsers in the same jar, but at least the architecture
> and the usage remains the same.
>

The same as what?

The CLI and Avalon APIs are different, so the usage cannot be the same for both.

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

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


Re: [cli2] Negative number arguments seen as options

Posted by Emmanuel Bourg <eb...@apache.org>.
sebb a écrit :

> But can this be done without breaking existing applications?

I think so. If these changes break the current spec we can still 
implement a new parser.

> Nor can one change the parser unless it maintains the same behaviour.
> 
> Unless the Avalon parser spec. agrees with the CLI1 spec, one will
> just end up with two separate CLI implementations in one jar.

You may have several parsers in the same jar, but at least the 
architecture and the usage remains the same.

Emmanuel Bourg

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


Re: [cli2] Negative number arguments seen as options

Posted by sebb <se...@gmail.com>.
On 31/05/2008, Emmanuel Bourg <eb...@apache.org> wrote:
> Russel Winder a écrit :
>
>
> > This would still leave the CLI 1.x--2.x problem, the APIs are different.
> > Past claims were that the 1.x API was not up to the task required of it.
> > sebb's argument for the Avalon API seems to back this up.
> >
>
>  The Avalon CLI looks closer to CLI1 than CLI2. I'd like to try adding the
> missing features to CLI1 to have a good basic API first before considering
> an hypothetical CLI2 API.
>
>
> > Some people
> > invented the 2.x API and then left the project to go stale.  Knowing why
> > the 2.x team disintegrated is an important factor here.  Was it everyone
> > got new jobs and had no time to work on it, or was it there was so much
> > technical feuding that progress was impossible.
> >
>
>  I looked at the CLI2 API and it seems much more complex, there are some
> concepts I'm not sure to agree with like the integrated i18n support or the
> excessive usage of interfaces/implementations. The CLI1 API seems much more
> straightforward to improve right now.
>

But can this be done without breaking existing applications?

Nor can one change the parser unless it maintains the same behaviour.

Unless the Avalon parser spec. agrees with the CLI1 spec, one will
just end up with two separate CLI implementations in one jar.

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

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


Re: [cli2] Negative number arguments seen as options

Posted by Emmanuel Bourg <eb...@apache.org>.
Russel Winder a écrit :

> This would still leave the CLI 1.x--2.x problem, the APIs are different.
> Past claims were that the 1.x API was not up to the task required of it.
> sebb's argument for the Avalon API seems to back this up.  

The Avalon CLI looks closer to CLI1 than CLI2. I'd like to try adding 
the missing features to CLI1 to have a good basic API first before 
considering an hypothetical CLI2 API.

> Some people
> invented the 2.x API and then left the project to go stale.  Knowing why
> the 2.x team disintegrated is an important factor here.  Was it everyone
> got new jobs and had no time to work on it, or was it there was so much
> technical feuding that progress was impossible.

I looked at the CLI2 API and it seems much more complex, there are some 
concepts I'm not sure to agree with like the integrated i18n support or 
the excessive usage of interfaces/implementations. The CLI1 API seems 
much more straightforward to improve right now.

Emmanuel Bourg

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


Re: [cli2] Negative number arguments seen as options

Posted by Russel Winder <ru...@concertant.com>.
On Fri, 2008-05-30 at 23:52 +0200, Emmanuel Bourg wrote:

> I'm going to convert the Avalon CLI test case to the Commons CLI API to 
> see what features are missing. I'll see if these features can be 
> implemented in CLI. So maybe we'll have a "common" API at last.

This would still leave the CLI 1.x--2.x problem, the APIs are different.
Past claims were that the 1.x API was not up to the task required of it.
sebb's argument for the Avalon API seems to back this up.  Some people
invented the 2.x API and then left the project to go stale.  Knowing why
the 2.x team disintegrated is an important factor here.  Was it everyone
got new jobs and had no time to work on it, or was it there was so much
technical feuding that progress was impossible.

So given that Google lands people looking for command line interpreters
with pages such as:

http://java-source.net/open-source/command-line

the Commons CLI as a project needs to take a view.

-- 
Russel.
====================================================
Dr Russel Winder                 Partner

Concertant LLP                   t: +44 20 7585 2200, +44 20 7193 9203
41 Buckmaster Road,              f: +44 8700 516 084
London SW11 1EN, UK.             m: +44 7770 465 077

Re: [cli2] Negative number arguments seen as options

Posted by Emmanuel Bourg <eb...@apache.org>.
sebb a écrit :

> Neither, as the CLI1 and CLI2 have a different API.
> 
> However, if the Avalon CLI were released, then JMeter could depend on
> it, and drop its own copy of the code.

I'm going to convert the Avalon CLI test case to the Commons CLI API to 
see what features are missing. I'll see if these features can be 
implemented in CLI. So maybe we'll have a "common" API at last.

Emmanuel Bourg

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


Re: [cli2] Negative number arguments seen as options

Posted by Russel Winder <ru...@concertant.com>.
On Fri, 2008-05-30 at 20:01 +0100, sebb wrote:

> > I guess this raises a critical question:
> 
> I don't see it as critical myself ...

Not critical to the JMeter project I agree, but it is critical to all
those people wondering what to do about command-line support.  There are
a large number of packages out there all claiming to be the "one true
way".  The fact that different Apache projects use different systems and
fork their own completely undermines any confidence in Commons CLI -- if
JMeter doesn't use Commons CLI then that is clearly a statement that an
Apache project has no confidence in the Apache project that is supposed
to represent the Apache way of doing things.

(OK, overstated, but you get my point I think.)

> >  Will JMeter remove its fork of
> >  Commons CLI, put the fixes into Commons CLI 1.2 and then depend on
> >  Commons CLI 1.2 -- or alternatively remove the Commons CLI 1.x fork and
> >  depend on Commons CLI 2.0-SNAPSHOT?
> 
> Neither, as the CLI1 and CLI2 have a different API.
> 
> However, if the Avalon CLI were released, then JMeter could depend on
> it, and drop its own copy of the code.

Quod erat demonstrandum, I'm afraid.
-- 
Russel.
====================================================
Dr Russel Winder                 Partner

Concertant LLP                   t: +44 20 7585 2200, +44 20 7193 9203
41 Buckmaster Road,              f: +44 8700 516 084
London SW11 1EN, UK.             m: +44 7770 465 077

Re: [cli2] Negative number arguments seen as options

Posted by sebb <se...@gmail.com>.
On 30/05/2008, Russel Winder <ru...@concertant.com> wrote:
> On Thu, 2008-05-29 at 16:40 +0100, sebb wrote:
>
>  > JMeter originally used the CLI code from Excalibur/Avalon, but the
>  > project appeared defunct so when some bugs needed fixing the CLI code
>  > was extracted, copied to JMeter and fixed.
>  >
>  > The Avalon CLI code in Commons is a copy of the JMeter version.
>  >
>  > Although Commons CLI is partly derived from Avalon, the interface is
>  > very different.
>
>
> I guess this raises a critical question:

I don't see it as critical myself ...

>  Will JMeter remove its fork of
>  Commons CLI, put the fixes into Commons CLI 1.2 and then depend on
>  Commons CLI 1.2 -- or alternatively remove the Commons CLI 1.x fork and
>  depend on Commons CLI 2.0-SNAPSHOT?

Neither, as the CLI1 and CLI2 have a different API.

However, if the Avalon CLI were released, then JMeter could depend on
it, and drop its own copy of the code.

>
>  --
>  Russel.
>  ====================================================
>  Dr Russel Winder                 Partner
>
>  Concertant LLP                   t: +44 20 7585 2200, +44 20 7193 9203
>  41 Buckmaster Road,              f: +44 8700 516 084
>  London SW11 1EN, UK.             m: +44 7770 465 077
>
>

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


Re: [cli2] Negative number arguments seen as options

Posted by Russel Winder <ru...@concertant.com>.
On Thu, 2008-05-29 at 16:40 +0100, sebb wrote:

> JMeter originally used the CLI code from Excalibur/Avalon, but the
> project appeared defunct so when some bugs needed fixing the CLI code
> was extracted, copied to JMeter and fixed.
> 
> The Avalon CLI code in Commons is a copy of the JMeter version.
> 
> Although Commons CLI is partly derived from Avalon, the interface is
> very different.

I guess this raises a critical question:  Will JMeter remove its fork of
Commons CLI, put the fixes into Commons CLI 1.2 and then depend on
Commons CLI 1.2 -- or alternatively remove the Commons CLI 1.x fork and
depend on Commons CLI 2.0-SNAPSHOT?

-- 
Russel.
====================================================
Dr Russel Winder                 Partner

Concertant LLP                   t: +44 20 7585 2200, +44 20 7193 9203
41 Buckmaster Road,              f: +44 8700 516 084
London SW11 1EN, UK.             m: +44 7770 465 077

Re: [cli2] Negative number arguments seen as options

Posted by sebb <se...@gmail.com>.
On 29/05/2008, Emmanuel Bourg <eb...@apache.org> wrote:
> sebb a écrit :
>
>
> > The Avalon CLI was added to SVN some while ago; it would be nice if it
> > could be released ;-)
> >
>
>  What is the difference between Avalon CLI and CLI1/CLI2 ?
>

JMeter originally used the CLI code from Excalibur/Avalon, but the
project appeared defunct so when some bugs needed fixing the CLI code
was extracted, copied to JMeter and fixed.

The Avalon CLI code in Commons is a copy of the JMeter version.

Although Commons CLI is partly derived from Avalon, the interface is
very different.

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

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


Re: [cli2] Negative number arguments seen as options

Posted by Emmanuel Bourg <eb...@apache.org>.
sebb a écrit :

> The Avalon CLI was added to SVN some while ago; it would be nice if it
> could be released ;-)

What is the difference between Avalon CLI and CLI1/CLI2 ?

Emmanuel Bourg

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


Re: [cli2] Negative number arguments seen as options

Posted by sebb <se...@gmail.com>.
Dare I say it:

this used to be a problem for the Avalon CLI package used by JMeter,
but it was fixed a long time ago. [The parser is very different so I
doubt the fix would apply to CLI2]

The Avalon CLI was added to SVN some while ago; it would be nice if it
could be released ;-)

On 21/05/2008, James Carman <ja...@carmanconsulting.com> wrote:
> FYI:
>
>  https://issues.apache.org/jira/browse/CLI-150
>
>
>
>  On Tue, May 20, 2008 at 11:22 PM, James Carman
>  <ja...@carmanconsulting.com> wrote:
>  > What type of parser are you using?
>  >
>  > On Tue, May 20, 2008 at 10:51 PM, Roland Roberts <ro...@astrofoto.org> wrote:
>  >> James Carman wrote:
>  >>>
>  >>> Why the leading space inside the quote?
>  >>>
>  >>
>  >> The first part of the answer was and is NO.  Quoting does not help.  Single
>  >> quotes, double quotes, backslashes, nada, nothing, zip, zilch, no effect.
>  >>
>  >> The second part of the answer was IF I DO and put the quote at the
>  >> beginning, then the parser does not consider it to be an option, but it
>  >> fails to convert to an integer.
>  >>
>  >> Quoting doesn't help.
>  >>
>  >> roland
>  >>>
>  >>> On Tue, May 20, 2008 at 5:51 PM, Roland Roberts <ro...@astrofoto.org>
>  >>> wrote:
>  >>>
>  >>>>
>  >>>> James Carman wrote:
>  >>>>
>  >>>>>
>  >>>>> Can you quote it?
>  >>>>>
>  >>>>
>  >>>> No.  If I do
>  >>>>
>  >>>> foo --value " -2"
>  >>>>
>  >>>> it "works" but then 'new Integer(" -2") throws NumberException; it
>  >>>> doesn't
>  >>>> like leading spaces.
>  >>
>  >> --
>  >>                       PGP Key ID: 66 BC 3B CD
>  >> Roland B. Roberts, PhD                             RL Enterprises
>  >> roland@rlenter.com                            6818 Madeline Court
>  >> roland@astrofoto.org                           Brooklyn, NY 11220
>  >>
>  >>
>  >> ---------------------------------------------------------------------
>  >> To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
>  >> For additional commands, e-mail: user-help@commons.apache.org
>  >>
>  >>
>  >
>
>  ---------------------------------------------------------------------
>  To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
>  For additional commands, e-mail: user-help@commons.apache.org
>
>

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


Re: [cli2] Negative number arguments seen as options

Posted by James Carman <ja...@carmanconsulting.com>.
FYI:

https://issues.apache.org/jira/browse/CLI-150


On Tue, May 20, 2008 at 11:22 PM, James Carman
<ja...@carmanconsulting.com> wrote:
> What type of parser are you using?
>
> On Tue, May 20, 2008 at 10:51 PM, Roland Roberts <ro...@astrofoto.org> wrote:
>> James Carman wrote:
>>>
>>> Why the leading space inside the quote?
>>>
>>
>> The first part of the answer was and is NO.  Quoting does not help.  Single
>> quotes, double quotes, backslashes, nada, nothing, zip, zilch, no effect.
>>
>> The second part of the answer was IF I DO and put the quote at the
>> beginning, then the parser does not consider it to be an option, but it
>> fails to convert to an integer.
>>
>> Quoting doesn't help.
>>
>> roland
>>>
>>> On Tue, May 20, 2008 at 5:51 PM, Roland Roberts <ro...@astrofoto.org>
>>> wrote:
>>>
>>>>
>>>> James Carman wrote:
>>>>
>>>>>
>>>>> Can you quote it?
>>>>>
>>>>
>>>> No.  If I do
>>>>
>>>> foo --value " -2"
>>>>
>>>> it "works" but then 'new Integer(" -2") throws NumberException; it
>>>> doesn't
>>>> like leading spaces.
>>
>> --
>>                       PGP Key ID: 66 BC 3B CD
>> Roland B. Roberts, PhD                             RL Enterprises
>> roland@rlenter.com                            6818 Madeline Court
>> roland@astrofoto.org                           Brooklyn, NY 11220
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
>> For additional commands, e-mail: user-help@commons.apache.org
>>
>>
>

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


Re: [cli2] Negative number arguments seen as options

Posted by James Carman <ja...@carmanconsulting.com>.
What type of parser are you using?

On Tue, May 20, 2008 at 10:51 PM, Roland Roberts <ro...@astrofoto.org> wrote:
> James Carman wrote:
>>
>> Why the leading space inside the quote?
>>
>
> The first part of the answer was and is NO.  Quoting does not help.  Single
> quotes, double quotes, backslashes, nada, nothing, zip, zilch, no effect.
>
> The second part of the answer was IF I DO and put the quote at the
> beginning, then the parser does not consider it to be an option, but it
> fails to convert to an integer.
>
> Quoting doesn't help.
>
> roland
>>
>> On Tue, May 20, 2008 at 5:51 PM, Roland Roberts <ro...@astrofoto.org>
>> wrote:
>>
>>>
>>> James Carman wrote:
>>>
>>>>
>>>> Can you quote it?
>>>>
>>>
>>> No.  If I do
>>>
>>> foo --value " -2"
>>>
>>> it "works" but then 'new Integer(" -2") throws NumberException; it
>>> doesn't
>>> like leading spaces.
>
> --
>                       PGP Key ID: 66 BC 3B CD
> Roland B. Roberts, PhD                             RL Enterprises
> roland@rlenter.com                            6818 Madeline Court
> roland@astrofoto.org                           Brooklyn, NY 11220
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
> For additional commands, e-mail: user-help@commons.apache.org
>
>

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


Re: [cli2] Negative number arguments seen as options

Posted by Roland Roberts <ro...@astrofoto.org>.
James Carman wrote:
> Why the leading space inside the quote?
>   
The first part of the answer was and is NO.  Quoting does not help.  
Single quotes, double quotes, backslashes, nada, nothing, zip, zilch, no 
effect.

The second part of the answer was IF I DO and put the quote at the 
beginning, then the parser does not consider it to be an option, but it 
fails to convert to an integer.

Quoting doesn't help.

roland
> On Tue, May 20, 2008 at 5:51 PM, Roland Roberts <ro...@astrofoto.org> wrote:
>   
>> James Carman wrote:
>>     
>>> Can you quote it?
>>>       
>> No.  If I do
>>
>> foo --value " -2"
>>
>> it "works" but then 'new Integer(" -2") throws NumberException; it doesn't
>> like leading spaces. 
>>     

-- 
		       PGP Key ID: 66 BC 3B CD
Roland B. Roberts, PhD                             RL Enterprises
roland@rlenter.com                            6818 Madeline Court
roland@astrofoto.org                           Brooklyn, NY 11220


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


Re: [cli2] Negative number arguments seen as options

Posted by James Carman <ja...@carmanconsulting.com>.
Why the leading space inside the quote?

On Tue, May 20, 2008 at 5:51 PM, Roland Roberts <ro...@astrofoto.org> wrote:
> James Carman wrote:
>>
>> Can you quote it?
>>
>
> No.  If I do
>
> foo --value " -2"
>
> it "works" but then 'new Integer(" -2") throws NumberException; it doesn't
> like leading spaces.  I can work around that to provide some way to get in
> negative values, but it just looks like a bug to me.  Particularly since I
> specified .withMinimum(1) for the argument, so the parser *has* to know
> there is an argument there.
>
> roland
>
> --
>                       PGP Key ID: 66 BC 3B CD
> Roland B. Roberts, PhD                             RL Enterprises
> roland@rlenter.com                            6818 Madeline Court
> roland@astrofoto.org                           Brooklyn, NY 11220
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
> For additional commands, e-mail: user-help@commons.apache.org
>
>

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


Re: [cli2] Negative number arguments seen as options

Posted by Roland Roberts <ro...@astrofoto.org>.
James Carman wrote:
> Can you quote it?
>   
No.  If I do

foo --value " -2"

it "works" but then 'new Integer(" -2") throws NumberException; it 
doesn't like leading spaces.  I can work around that to provide some way 
to get in negative values, but it just looks like a bug to me.  
Particularly since I specified .withMinimum(1) for the argument, so the 
parser *has* to know there is an argument there.

roland

-- 
		       PGP Key ID: 66 BC 3B CD
Roland B. Roberts, PhD                             RL Enterprises
roland@rlenter.com                            6818 Madeline Court
roland@astrofoto.org                           Brooklyn, NY 11220


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


Re: [cli2] Negative number arguments seen as options

Posted by James Carman <ja...@carmanconsulting.com>.
Can you quote it?

On Tue, May 20, 2008 at 5:12 PM, Roland Roberts <ro...@astrofoto.org> wrote:
> I just discovered that an option that takes an argument can't provide a
> negative value, --value -2 is seen as option "value" followed by option "2".
>  This is true even if I use NumberValidator; I tried that thinking it might
> provide a hint to the parser.
>
> 259 roland> cd commons-cli-2.0
> 260 roland> svn up
> At revision 658435.
>
>
> roland
>
> --
>                       PGP Key ID: 66 BC 3B CD
> Roland B. Roberts, PhD                             RL Enterprises
> roland@rlenter.com                            6818 Madeline Court
> roland@astrofoto.org                           Brooklyn, NY 11220
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
> For additional commands, e-mail: user-help@commons.apache.org
>
>

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