Description
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:
Main.java
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
Attachments
Issue Links
- duplicates
-
CLI-186 Standard help text will not show mandatory arguments for first option
- Closed