Skip to content

Commit

Permalink
Show which options are discriminating in the output of mvnd --help
Browse files Browse the repository at this point in the history
  • Loading branch information
ppalaga committed May 22, 2023
1 parent c177fe2 commit ffa10fb
Showing 1 changed file with 13 additions and 10 deletions.
23 changes: 13 additions & 10 deletions daemon/src/main/java/org/apache/maven/cli/MvndHelpFormatter.java
Original file line number Diff line number Diff line change
Expand Up @@ -121,8 +121,15 @@ public static String displayHelp(CLIManager cliManager) {
spaces(help, indentPos - help.length());
wrap(help, toPlainText(entry.getJavaDoc()), terminalWidth, lineEnd, indent);

indentedLine(help, terminalWidth, "Default", env.getDefault(), indent);
indentedLine(help, terminalWidth, "Env. variable", env.getEnvironmentVariable(), indent);
if (env.isDiscriminating()) {
indentedLine(help, terminalWidth, "This is a discriminating start parameter.", indent);
}
if (env.getDefault() != null) {
indentedLine(help, terminalWidth, "Default: " + env.getDefault(), indent);
}
if (env.getEnvironmentVariable() != null) {
indentedLine(help, terminalWidth, "Env. variable:" + env.getEnvironmentVariable(), indent);
}
});

help.append(lineSeparator).append(lineSeparator).append("mvnd value types:");
Expand Down Expand Up @@ -151,14 +158,10 @@ private static int getTerminalWidth() {
return terminalWidth;
}

private static void indentedLine(
StringBuilder stringBuilder, int terminalWidth, String key, String value, String indent) {
int lineEnd;
if (value != null) {
lineEnd = stringBuilder.length() + terminalWidth;
stringBuilder.append(System.lineSeparator()).append(indent);
wrap(stringBuilder, key + ": " + value, terminalWidth, lineEnd, indent);
}
private static void indentedLine(StringBuilder stringBuilder, int terminalWidth, String text, String indent) {
final int lineEnd = stringBuilder.length() + terminalWidth;
stringBuilder.append(System.lineSeparator()).append(indent);
wrap(stringBuilder, text, terminalWidth, lineEnd, indent);
}

/**
Expand Down

0 comments on commit ffa10fb

Please sign in to comment.