Skip to content

Commit

Permalink
Handle help command
Browse files Browse the repository at this point in the history
  • Loading branch information
ghubstan committed Mar 30, 2020
1 parent d3e60fa commit cefb679
Showing 2 changed files with 6 additions and 2 deletions.
6 changes: 5 additions & 1 deletion cli/src/main/java/bisq/cli/app/BisqCliMain.java
Original file line number Diff line number Diff line change
@@ -31,6 +31,7 @@

import static bisq.cli.app.CommandParser.GETBALANCE;
import static bisq.cli.app.CommandParser.GETVERSION;
import static bisq.cli.app.CommandParser.HELP;
import static bisq.cli.app.CommandParser.STOPSERVER;
import static java.lang.String.format;
import static java.lang.System.exit;
@@ -77,6 +78,9 @@ private BisqCliMain(ManagedChannel channel) {
private String runCommand(String command) {
final String result;
switch (command) {
case HELP:
CommandParser.printHelp();
exit(EXIT_SUCCESS);
case GETBALANCE:
long satoshis = cmd.getBalance();
result = satoshis == -1 ? "Server initializing..." : cmd.prettyBalance.apply(satoshis);
@@ -99,7 +103,7 @@ private String parseCommand(String[] params) {
OptionSet options = parser.parse(params);
List<String> detectedOptions = nonOptions.values(options);
if (detectedOptions.isEmpty()) {
CommandParser.printUsage();
CommandParser.printHelp();
exit(EXIT_FAILURE);
}
return detectedOptions.get(0);
2 changes: 1 addition & 1 deletion cli/src/main/java/bisq/cli/app/CommandParser.java
Original file line number Diff line number Diff line change
@@ -20,7 +20,7 @@ OptionParser configure() {
return parser;
}

static void printUsage() {
static void printHelp() {
out.println("Usage: bisq-cli getbalance | getversion");
}

0 comments on commit cefb679

Please sign in to comment.