From dee8e5baa8dfa9ce4dbcb2921d3835d87a11f250 Mon Sep 17 00:00:00 2001 From: ghubstan <36207203+ghubstan@users.noreply.github.com> Date: Thu, 30 Jun 2022 13:13:35 -0300 Subject: [PATCH] Add convenience for lgging combination of copy/paste CLI cmds for peer --- .../src/main/java/bisq/bots/BotUtils.java | 18 +++++++++++++++++- .../bots/RegtestTradePaymentSimulator.java | 9 ++++----- 2 files changed, 21 insertions(+), 6 deletions(-) diff --git a/java-examples/src/main/java/bisq/bots/BotUtils.java b/java-examples/src/main/java/bisq/bots/BotUtils.java index b433ace..2db1f38 100644 --- a/java-examples/src/main/java/bisq/bots/BotUtils.java +++ b/java-examples/src/main/java/bisq/bots/BotUtils.java @@ -552,7 +552,6 @@ public class BotUtils { log.warn(BANNER); } - /** * Log a CLI gettrade command for a simulated trading peer. * @@ -574,6 +573,23 @@ public class BotUtils { log.warn(BANNER); } + /** + * Log 1 or more CLI commands for a simulated trading peer. + * Commands need to be separated by newlines to be legible. + * + * @param log calling bot's logger + * @param description description of CLI commands + * @param commands CLI commands separated by newlines. + */ + public static void printCliCommands(Logger log, + String description, + String commands) { + log.warn(BANNER); + log.warn(description); + log.warn(commands); + log.warn(BANNER); + } + /** * Run a bash script to count down the given number of seconds, printing each character of output from stdout. *
diff --git a/java-examples/src/main/java/bisq/bots/RegtestTradePaymentSimulator.java b/java-examples/src/main/java/bisq/bots/RegtestTradePaymentSimulator.java index c48e364..a57eac3 100644 --- a/java-examples/src/main/java/bisq/bots/RegtestTradePaymentSimulator.java +++ b/java-examples/src/main/java/bisq/bots/RegtestTradePaymentSimulator.java @@ -105,12 +105,11 @@ public class RegtestTradePaymentSimulator extends AbstractBot { closeTrade(tradeId); log.info("You closed the trade here in the bot (mandatory, to move trades to history list)."); - log.warn("##############################################################################"); - log.warn("Bob closes trade in the CLI (mandatory, to move trades to history list):"); - String copyPasteCliCommands = "./bisq-cli --password=xyz --port=9999 closetrade --trade-id=" + trade.getTradeId() + String cliCommandDescription = "Trading peer inspects and closes trade in the CLI (mandatory, to move trades to history list):"; + String copyPasteCliCommands = "./bisq-cli --password=xyz --port=9999 gettrade --trade-id=" + trade.getTradeId() + + "\n" + "./bisq-cli --password=xyz --port=9999 closetrade --trade-id=" + trade.getTradeId() + "\n" + "./bisq-cli --password=xyz --port=9999 gettrades --category=closed"; - log.warn(copyPasteCliCommands); - log.warn("##############################################################################"); + printCliCommands(log, cliCommandDescription, copyPasteCliCommands); log.debug("Closing {}'s gRPC channel.", this.getClass().getSimpleName()); super.grpcStubs.close();