Skip to content

Commit 1e57e38

Browse files
committed
feat: use new commons-cli HelpFormatter
Replace deprecated `org.apache.commons.cli.HelpFormatter` with the new `org.apache.commons.cli.help.HelpFormatter`
1 parent f722091 commit 1e57e38

1 file changed

Lines changed: 7 additions & 4 deletions

File tree

  • src/main/java/de/bwravencl/controllerbuddy/gui

src/main/java/de/bwravencl/controllerbuddy/gui/Main.java

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -218,9 +218,10 @@
218218
import org.apache.batik.util.XMLResourceDescriptor;
219219
import org.apache.commons.cli.CommandLine;
220220
import org.apache.commons.cli.DefaultParser;
221-
import org.apache.commons.cli.HelpFormatter;
222221
import org.apache.commons.cli.Options;
223222
import org.apache.commons.cli.ParseException;
223+
import org.apache.commons.cli.help.HelpFormatter;
224+
import org.apache.commons.cli.help.TextHelpAppendable;
224225
import org.freedesktop.dbus.annotations.DBusBoundProperty;
225226
import org.freedesktop.dbus.annotations.DBusInterfaceName;
226227
import org.freedesktop.dbus.annotations.DBusProperty.Access;
@@ -1741,10 +1742,12 @@ public static void main(final String[] args) {
17411742

17421743
final var stringWriter = new StringWriter();
17431744
try (final var printWriter = new PrintWriter(stringWriter)) {
1744-
final var helpFormatter = new HelpFormatter();
1745-
helpFormatter.printHelp(printWriter, helpFormatter.getWidth(), Constants.APPLICATION_NAME, null, OPTIONS,
1746-
helpFormatter.getLeftPadding(), helpFormatter.getDescPadding(), null, true);
1745+
final var helpFormatter = HelpFormatter.builder().setHelpAppendable(new TextHelpAppendable(printWriter))
1746+
.setShowSince(false).get();
1747+
helpFormatter.printHelp(Constants.APPLICATION_NAME, null, OPTIONS, null, true);
17471748
printWriter.flush();
1749+
} catch (final IOException e) {
1750+
throw new RuntimeException(e);
17481751
}
17491752
printCommandLineMessage(stringWriter.toString());
17501753
}

0 commit comments

Comments
 (0)