Issue Details (XML | Word | Printable)

Key: CLI-38
Type: Bug Bug
Status: Closed Closed
Resolution: Fixed
Priority: Major Major
Assignee: Unassigned
Reporter: steve
Votes: 0
Watchers: 0
Operations

If you were logged in you would be able to see more operations.
Commons CLI

[cli] HelpFormatter doesn't function correctly for options with only LongOpt

Created: 02/Feb/05 07:45 AM   Updated: 15/May/07 09:24 PM
Return to search
Component/s: CLI-1.x
Affects Version/s: 1.0
Fix Version/s: 1.1

Time Tracking:
Not Specified

File Attachments:
  Size
Text File proposed-patch.txt 2005-02-02 09:57 AM steve 2 kB
Environment:
Operating System: All
Platform: All

Bugzilla Id: 33340


 Description  « Hide
The following doesn't work (org.apache.commons.cli.HelpFormatter
)correctly and doesn't print out the help menu of options
that only specify LongOpt.

The output is:
[java] usage: -a | -d | --shutdown | -s | -h [-r <email>] [-f <flight>] [-t]
[java] VendMore - Email Management System
[java] t,-test test mode - makes no permanent changes.
[java] --shutdown shutdown rpc server.
[java] a,-add add user to email queue.
[java] d,-delete delete user from email queue.
[java] f,-flight flight which is the index into the email being sent
[java] h,-help Print this usage information.
[java] -r recipient's email
[java] s,-send send email command
[java] For more information, see Steve Morin
[java] Java Result: 1

it is missing the following options when printing the help display.

options.addOption(OptionBuilder.withDescription("hostname for the XmlRpc
client to connect to.").withLongOpt("hostname").create());
options.addOption(OptionBuilder.withDescription("port for the xmlrpc
client to use.").withLongOpt("port").create());
options.addOption(OptionBuilder.withDescription("additional xmlrpc
connection").withLongOpt("urlpath").create());
options.addOption(OptionBuilder.withDescription("add a parameter
form name=value.").hasArg().withLongOpt("params").create());

example of the offending code

private CommandLineParser cmd;
private Options options;
private OptionGroup ogmain;

public CmdLineArg() { super(); cmd = new BasicParser(); options = new Options(); ogmain = new OptionGroup(); ogmain.setRequired(true); localinit(); init(); }

public CommandLine run(String[] args) {

try { options.addOption(OptionBuilder.withDescription("add a parameter form name=value.").hasArg().withLongOpt("params").create()); options.addOption(OptionBuilder.withDescription("recipient's email").hasArg().create('r')); options.addOption(OptionBuilder.withDescription("flight which is the index into the email being sent").withLongOpt("flight").hasArg().create('f')); options.addOption(OptionBuilder.withDescription("test mode - makes no permanent changes.").withLongOpt("test").create('t')); ogmain.addOption(OptionBuilder.withDescription("Print this usage information.").withLongOpt("help").create('h')); ogmain.addOption(OptionBuilder.withDescription("send email command").withLongOpt("send").hasArg().create('s')); ogmain.addOption(OptionBuilder.withDescription("add user to email queue.").withLongOpt("add").create('a')); ogmain.addOption(OptionBuilder.withDescription("delete user from email queue.").withLongOpt("delete").create('d')); ogmain.addOption(OptionBuilder.withDescription("shutdown rpc server.").withLongOpt("shutdown").create()); options.addOption(OptionBuilder.withDescription("hostname for the XmlRpc client to connect to.").withLongOpt("hostname").create()); options.addOption(OptionBuilder.withDescription("port for the xmlrpc client to use.").withLongOpt("port").create()); options.addOption(OptionBuilder.withDescription("additional xmlrpc connection").withLongOpt("urlpath").create()); options.addOptionGroup(this.ogmain); return cmd.parse(options,args); } catch (ParseException e) { printUsage(); System.exit(1); return null; }
}

protected void printUsage(){ HelpFormatter helpFormatter = new HelpFormatter(); helpFormatter.printHelp(getUSAGE(),getHEADER(),options,getFOOTER()); }



 All   Comments   Work Log   Change History   Subversion Commits      Sort Order: Ascending order - Click to sort in descending order
Henri Yandell made changes - 16/May/06 09:51 AM
Field Original Value New Value
issue.field.bugzillaimportkey 33340 12342029
Henri Yandell made changes - 16/May/06 11:12 AM
Project Commons [ 12310458 ] Commons CLI [ 12310463 ]
Assignee Jakarta Commons Developers Mailing List [ commons-dev@jakarta.apache.org ]
Affects Version/s 1.0 Final [ 12311651 ]
Component/s CLI [ 12311104 ]
Key COM-1877 CLI-38
Henri Yandell made changes - 16/May/06 12:16 PM
Affects Version/s 1.0 Final [ 12311698 ]
Henri Yandell made changes - 10/Jul/06 01:16 PM
Fix Version/s 1.1 [ 12311979 ]
Bugzilla Id 33340
Henri Yandell made changes - 15/Mar/07 04:36 PM
Component/s CLI-1.x [ 12311672 ]
Henri Yandell made changes - 15/Mar/07 04:49 PM
Status Resolved [ 5 ] Closed [ 6 ]