From 1f09060975a6a19581ebc838453c53542dccb6dc Mon Sep 17 00:00:00 2001 From: ghubstan <36207203+ghubstan@users.noreply.github.com> Date: Wed, 29 Jun 2022 15:30:50 -0300 Subject: [PATCH] Extend option help col-width (no wrapping) --- .../src/main/java/bisq/bots/Config.java | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/java-examples/src/main/java/bisq/bots/Config.java b/java-examples/src/main/java/bisq/bots/Config.java index 7438073..64a1c97 100644 --- a/java-examples/src/main/java/bisq/bots/Config.java +++ b/java-examples/src/main/java/bisq/bots/Config.java @@ -17,6 +17,7 @@ package bisq.bots; +import joptsimple.BuiltinHelpFormatter; import joptsimple.OptionParser; import lombok.Getter; import lombok.extern.slf4j.Slf4j; @@ -63,12 +64,12 @@ public class Config { .withRequiredArg(); var confOpt = parser.accepts("conf", "Bot configuration file (required)") .withRequiredArg(); - var dryRunOpt = parser.accepts("dryrun", "Pretend to take an offer (default=false)") + var dryRunOpt = parser.accepts("dryrun", "Pretend to take an offer") .withRequiredArg() .ofType(boolean.class) .defaultsTo(FALSE); var simulateRegtestPaymentStepsOpt = - parser.accepts("simulate-regtest-payment", "Simulate regtest payment steps (default=false)") + parser.accepts("simulate-regtest-payment", "Simulate regtest payment steps") .withOptionalArg() .ofType(boolean.class) .defaultsTo(FALSE); @@ -126,10 +127,23 @@ public class Config { stream.println(); stream.println("Usage: ScriptName [options]"); stream.println(); + parser.formatHelpWith(new HelpFormatter(90, 2)); parser.printHelpOn(stream); stream.println(); } catch (IOException ex) { ex.printStackTrace(stream); } } + + private static class HelpFormatter extends BuiltinHelpFormatter { + /** + * Makes a formatter with a given overall row width and column separator width. + * + * @param desiredOverallWidth how many characters wide to make the overall help display + * @param desiredColumnSeparatorWidth how many characters wide to make the separation between option column and + */ + public HelpFormatter(int desiredOverallWidth, int desiredColumnSeparatorWidth) { + super(desiredOverallWidth, desiredColumnSeparatorWidth); + } + } }