Skip to content

Commit

Permalink
Append newline character instead of string
Browse files Browse the repository at this point in the history
  • Loading branch information
hogejo committed Dec 1, 2024
1 parent 8774cba commit 4b1422c
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 12 deletions.
20 changes: 10 additions & 10 deletions src/main/java/com/beust/jcommander/DefaultUsageFormatter.java
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public final void usage(String commandName, StringBuilder out, String indent) {

if (description != null) {
out.append(indent).append(description);
out.append("\n");
out.append('\n');
}
jc.getUsageFormatter().usage(out, indent);
}
Expand Down Expand Up @@ -154,7 +154,7 @@ public void appendMainLine(StringBuilder out, boolean hasOptions, boolean hasCom
mainLine.append(" ").append(commander.getMainParameter().getDescription().getDescription());
}
wrapDescription(out, indentCount, mainLine.toString());
out.append("\n");
out.append('\n');
}

/**
Expand All @@ -169,7 +169,7 @@ public void appendMainLine(StringBuilder out, boolean hasOptions, boolean hasCom
public void appendAllParametersDetails(StringBuilder out, int indentCount, String indent,
List<ParameterDescription> sortedParameters) {
if (sortedParameters.size() > 0) {
out.append("\n");
out.append('\n');
out.append(indent).append(" Options:\n");
}

Expand All @@ -183,7 +183,7 @@ public void appendAllParametersDetails(StringBuilder out, int indentCount, Strin
.append(" ")
.append(parameter.required() ? "* " : " ")
.append(pd.getNames())
.append("\n");
.append('\n');

if (hasDescription) {
wrapDescription(out, indentCount, s(indentCount) + description);
Expand Down Expand Up @@ -242,7 +242,7 @@ public void appendAllParametersDetails(StringBuilder out, int indentCount, Strin
out.append(possibleValues);
}
}
out.append("\n");
out.append('\n');
}
}

Expand Down Expand Up @@ -270,18 +270,18 @@ public void appendCommands(StringBuilder out, int indentCount, int descriptionIn
if (hasOnlyHiddenCommands)
return;

out.append("\n");
out.append('\n');
out.append(indent + " Commands:\n");

boolean firstCommand = true;
var firstCommand = true;
// The magic value 3 is the number of spaces between the name of the option and its description
for (Map.Entry<JCommander.ProgramName, JCommander> commands : commander.getRawCommands().entrySet()) {
Object arg = commands.getValue().getObjects().get(0);
Parameters p = arg.getClass().getAnnotation(Parameters.class);

if (p == null || !p.hidden()) {
if (!firstCommand) {
out.append("\n");
out.append('\n');
} else {
firstCommand = false;
}
Expand All @@ -292,7 +292,7 @@ public void appendCommands(StringBuilder out, int indentCount, int descriptionIn
.orElse("");
String description = indent + s(4) + dispName + commandDescription;
wrapDescription(out, indentCount + descriptionIndent, description);
out.append("\n");
out.append('\n');

// Options for this command
JCommander jc = commander.findCommandByAlias(progName.getName());
Expand Down Expand Up @@ -369,7 +369,7 @@ public void wrapDescription(StringBuilder out, int indent, int currentLineIndent
current++;
}
} else {
out.append("\n").append(s(indent)).append(word).append(" ");
out.append('\n').append(s(indent)).append(word).append(" ");
current = indent + word.length() + 1;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ public void appendAllParametersDetails(StringBuilder out, int indentCount, Strin
// The magic value 3 is the number of spaces between the name of the option and its description
// in DefaultUsageFormatter#appendCommands(..)
wrapDescription(out, indentCount + prefixIndent - 3, initialLinePrefixLength, description);
out.append("\n");
out.append('\n');
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public void print(String msg) {
@Override
public void println(String msg) {
print(msg);
output.append("\n");
output.append('\n');
}

@Override
Expand Down

0 comments on commit 4b1422c

Please sign in to comment.