Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -486,39 +486,40 @@ public void substitute(UnaryOperator<String> callback) {
* @throws IOException if an error occurs
*/
protected void saveLayout(Writer out, boolean typed) throws IOException {
PropertiesWriter writer = new PropertiesWriter(out, typed);
if (header != null) {
for (String s : header) {
writer.writeln(s);
}
}
try (PropertiesWriter writer = new PropertiesWriter(out, typed)) {

for (String key : storage.keySet()) {
Layout l = layout.get(key);
if (l != null && l.getCommentLines() != null) {
for (String s : l.getCommentLines()) {
if (header != null) {
for (String s : header) {
writer.writeln(s);
}
}
if (l != null && l.getValueLines() != null) {
for (int i = 0; i < l.getValueLines().size(); i++) {
String s = l.getValueLines().get(i);
if (i < l.getValueLines().size() - 1) {
writer.writeln(s + "\\");
} else {

for (String key : storage.keySet()) {
Layout l = layout.get(key);
if (l != null && l.getCommentLines() != null) {
for (String s : l.getCommentLines()) {
writer.writeln(s);
}
}
} else {
writer.writeProperty(key, storage.get(key));
if (l != null && l.getValueLines() != null) {
for (int i = 0; i < l.getValueLines().size(); i++) {
String s = l.getValueLines().get(i);
if (i < l.getValueLines().size() - 1) {
writer.writeln(s + "\\");
} else {
writer.writeln(s);
}
}
} else {
writer.writeProperty(key, storage.get(key));
}
}
}
if (footer != null) {
for (String s : footer) {
writer.writeln(s);
if (footer != null) {
for (String s : footer) {
writer.writeln(s);
}
}
}
writer.flush();
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -473,18 +473,18 @@ public void displayHelp(String command, Consumer<String> pw) {
pw.accept("");

StringWriter sw = new StringWriter();
PrintWriter pw2 = new PrintWriter(sw);
formatter.printHelp(
pw2,
width,
commandLineSyntax(command),
System.lineSeparator() + "Options:",
options,
HelpFormatter.DEFAULT_LEFT_PAD,
HelpFormatter.DEFAULT_DESC_PAD,
System.lineSeparator(),
false);
pw2.flush();
try (PrintWriter writer = new PrintWriter(sw)) {
formatter.printHelp(
writer,
width,
commandLineSyntax(command),
System.lineSeparator() + "Options:",
options,
HelpFormatter.DEFAULT_LEFT_PAD,
HelpFormatter.DEFAULT_DESC_PAD,
System.lineSeparator(),
false);
}
for (String s : sw.toString().split(System.lineSeparator())) {
pw.accept(s);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -407,11 +407,7 @@ protected Consumer<String> doDetermineWriter(C context) {
} else {
// Given the terminal creation has been offloaded to a different thread,
// do not pass directly the terminal writer
return msg -> {
PrintWriter pw = context.terminal.writer();
pw.println(msg);
pw.flush();
};
return msg -> context.terminal.writer().println(msg);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -485,39 +485,39 @@ public void substitute(UnaryOperator<String> callback) {
* @throws IOException if an error occurs
*/
protected void saveLayout(Writer out, boolean typed) throws IOException {
PropertiesWriter writer = new PropertiesWriter(out, typed);
if (header != null) {
for (String s : header) {
writer.writeln(s);
}
}

for (String key : storage.keySet()) {
Layout l = layout.get(key);
if (l != null && l.getCommentLines() != null) {
for (String s : l.getCommentLines()) {
try (PropertiesWriter writer = new PropertiesWriter(out, typed)) {
if (header != null) {
for (String s : header) {
writer.writeln(s);
}
}
if (l != null && l.getValueLines() != null) {
for (int i = 0; i < l.getValueLines().size(); i++) {
String s = l.getValueLines().get(i);
if (i < l.getValueLines().size() - 1) {
writer.writeln(s + "\\");
} else {

for (String key : storage.keySet()) {
Layout l = layout.get(key);
if (l != null && l.getCommentLines() != null) {
for (String s : l.getCommentLines()) {
writer.writeln(s);
}
}
} else {
writer.writeProperty(key, storage.get(key));
if (l != null && l.getValueLines() != null) {
for (int i = 0; i < l.getValueLines().size(); i++) {
String s = l.getValueLines().get(i);
if (i < l.getValueLines().size() - 1) {
writer.writeln(s + "\\");
} else {
writer.writeln(s);
}
}
} else {
writer.writeProperty(key, storage.get(key));
}
}
}
if (footer != null) {
for (String s : footer) {
writer.writeln(s);
if (footer != null) {
for (String s : footer) {
writer.writeln(s);
}
}
}
writer.flush();
}

/**
Expand Down
Loading