jcommander
jcommander copied to clipboard
Wrong indentation when mixing single and multiple form parameters
Sounds like I've get a wrong indentation when doing this:
@Parameter(names = { "--help"}, help = true, description = "Display help")
private boolean help;
@Parameter(names = { "--verbose", "-v" }, description = "Debug mode")
private boolean debug = false;
Output is:
Usage: river [options]
Options:
--verbose, -v
Debug mode
Default: false
--help
Display help
Default: false
When using:
@Parameter(names = { "--help", "-h", "-?"}, help = true, description = "Display help")
private boolean help;
@Parameter(names = { "--verbose", "-v" }, description = "Debug mode")
private boolean debug = false;
Output is this time correct:
Usage: river [options]
Options:
--verbose, -v
Debug mode
Default: false
--help, -h, -?
Display help
Default: false
This fixes the indentation:
diff --git a/src/main/java/com/beust/jcommander/ParameterDescription.java b/src/main/java/com/beust/jcommander/ParameterDescription.java
index 33574a9..8217598 100644
--- a/src/main/java/com/beust/jcommander/ParameterDescription.java
+++ b/src/main/java/com/beust/jcommander/ParameterDescription.java
@@ -186,7 +186,6 @@ public class ParameterDescription {
String[] names = m_wrappedParameter.names();
for (int i = 0; i < names.length; i++) {
if (i > 0) sb.append(", ");
- if (names.length == 1 && names[i].startsWith("--")) sb.append(" ");
sb.append(names[i]);
}
return sb.toString();
The ways to work around it are to have more than one option name, or to use a single dash even for long option names.
The commit message for that line reads:
commit 0dcc308f1c08b831376a3e153e2a1ed1a6166697 Author: Cedric Beust [email protected] Date: Sat Nov 27 12:53:20 2010 -0800
Better usage().
Now sorting correctly and aligning -- options on the same column.