Brian Pontarelli created CLI-233:
------------------------------------
Summary: HelpFormatter missing <arg> for first option
Key: CLI-233
URL: https://issues.apache.org/jira/browse/CLI-233
Project: Commons CLI
Issue Type: Bug
Components: CLI-1.x
Affects Versions: 1.2
Reporter: Brian Pontarelli
Priority: Minor
Fix For: 1.3
I'm not sure if this is fixed in the master branch, but it looks like the
HelpFormatter doesn't correctly output a <arg> when the first option has an
argument. Sample:
Options options = new Options();
options.addOption(OptionBuilder.withLongOpt("user").withDescription("Database
username").isRequired().hasArg().create("u"));
options.addOption(OptionBuilder.withLongOpt("pass").withDescription("Database
password").isRequired().hasArg().create("p"));
CommandLineParser parser = new PosixParser();
CommandLine commandLine;
try {
commandLine = parser.parse(options, args);
} catch (ParseException e) {
HelpFormatter helpFormatter = new HelpFormatter();
helpFormatter.printHelp(120, "Usage: Main <options>", e.getMessage(),
options, "");
System.exit(1);
}
The output is:
usage: Usage: Main <options>
Missing required option: u, p
-p,--pass <arg> Database password
-u,--user Database username
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira