commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From DeSmet_Ri...@emc.com
Subject [CLI] Inconsistency in Options.hasOption(String)
Date Mon, 10 Feb 2003 11:56:14 GMT
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

Mime
View raw message