commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From John Keyes <j...@mac.com>
Subject Re: [CLI] RESEND: Inconsistency in Options.hasOption(String)
Date Sat, 15 Feb 2003 19:44:19 GMT
Hi Ringo,

The behaviour you describe is incorrect.  I have this on my todo
list (sorry for not responding to your first mail).

-John K

On Friday, Feb 14, 2003, at 13:45 Europe/Dublin, DeSmet_Ringo@emc.com 
wrote:

> Hello,
>
> I think there is an inconsistency in the method 
> Options.hasOption(String).
> The Javadoc mentions that the method argument is either the long or 
> short
> name of the option. However, the following snippet doesn't give me the
> expected results.
>
> org.apache.commons.cli.Options options = new
> org.apache.commons.cli.Options();
> options.addOption(org.apache.commons.cli.OptionBuilder
> .withLongOpt("cluster")
> .create());
>
> System.out.println("Has long  'cluster' option? " +
> options.hasOption("cluster"));
> System.out.println("Has short 'cluster' option? " + 
> options.hasOption(" "));
>
> The output is:
>
> Has long  'cluster' option? false
> Has short 'cluster' option? true
>
> However, if I specify this:
>
> System.out.println("Has long  'cluster' option? " +
> options.hasOption("--cluster"));
>
> The output is:
>
> Has long  'cluster' option? true
>
> Why should I specify the "--" for the long option and not "-" for the 
> short
> one? I think you should only have to specify the short or long option 
> name
> withouth any colon (as documented).
>
> Ringo
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: commons-user-help@jakarta.apache.org
>
>
- - - - - - - - - - - - - - - - - - - - - - -
Jakarta Commons CLI
http://jakarta.apache.org/commons/cli


Mime
View raw message