You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by Matthieu Bentot <ma...@eircom.net> on 2003/09/07 23:40:55 UTC

Bug in CLI

Hi,

Err, there is a bug in commons-cli, the OptionBuilder implicitely 
initializes
argNames with null, so the first option created, if it takes arguments, 
will have
them with no names, hence not listed by the HelpFormatter.

The "patch" follows (if at all needed ;-):

diff -c -r1.15 OptionBuilder.java
*** cli/src/java/org/apache/commons/cli/OptionBuilder.java      9 Dec 
2002 23:47:24 -0000       1.15
--- cli/src/java/org/apache/commons/cli/OptionBuilder.java      7 Sep 
2003 22:21:15 -0000
***************
*** 79,85 ****
       private static String description;

       /** argument name */
!     private static String argName;

       /** is required? */
       private static boolean required;
--- 79,85 ----
       private static String description;

       /** argument name */
!     private static String argName = "arg";

       /** is required? */
       private static boolean required;

Great stuff, BTW. Being able to write a complete CLI parser in 10 
lines, plus the free help print, gotta love that.

Cheers,

Matthieu


Re: Bug in CLI

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

Thanks very much for the patch.  We hope to have a new version of
CLI out soon, so we have suspended development of the version 1
code.

-John K

On Sunday, September 7, 2003, at 10:40 PM, Matthieu Bentot wrote:

> Hi,
>
> Err, there is a bug in commons-cli, the OptionBuilder implicitely 
> initializes
> argNames with null, so the first option created, if it takes 
> arguments, will have
> them with no names, hence not listed by the HelpFormatter.
>
> The "patch" follows (if at all needed ;-):
>
> diff -c -r1.15 OptionBuilder.java
> *** cli/src/java/org/apache/commons/cli/OptionBuilder.java      9 Dec 
> 2002 23:47:24 -0000       1.15
> --- cli/src/java/org/apache/commons/cli/OptionBuilder.java      7 Sep 
> 2003 22:21:15 -0000
> ***************
> *** 79,85 ****
>       private static String description;
>
>       /** argument name */
> !     private static String argName;
>
>       /** is required? */
>       private static boolean required;
> --- 79,85 ----
>       private static String description;
>
>       /** argument name */
> !     private static String argName = "arg";
>
>       /** is required? */
>       private static boolean required;
>
> Great stuff, BTW. Being able to write a complete CLI parser in 10 
> lines, plus the free help print, gotta love that.
>
> Cheers,
>
> Matthieu
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: commons-dev-help@jakarta.apache.org
>