X-Git-Url: https://git.nmode.ca/signal-cli/blobdiff_plain/14c8f07b8d173eb162511075da1b4b1108773768..a2debdb2347b103c6b49b5b2dacfcfabb27fff71:/src/main/java/org/asamk/signal/Cli.java diff --git a/src/main/java/org/asamk/signal/Cli.java b/src/main/java/org/asamk/signal/Cli.java index 9f7048ad..f8e2e9ab 100644 --- a/src/main/java/org/asamk/signal/Cli.java +++ b/src/main/java/org/asamk/signal/Cli.java @@ -39,7 +39,7 @@ import java.util.stream.Collectors; public class Cli { - private final static Logger logger = LoggerFactory.getLogger(Main.class); + private final static Logger logger = LoggerFactory.getLogger(Cli.class); private final Namespace ns; @@ -65,8 +65,8 @@ public class Cli { parser.addArgument("-o", "--output") .help("Choose to output in plain text or JSON") - .choices("plain-text", "json") - .setDefault("plain-text"); + .type(Arguments.enumStringType(OutputType.class)) + .setDefault(OutputType.PLAIN_TEXT); Subparsers subparsers = parser.addSubparsers().title("subcommands").dest("command"); @@ -91,6 +91,12 @@ public class Cli { return 1; } + OutputType outputType = ns.get("output"); + if (!command.getSupportedOutputTypes().contains(outputType)) { + logger.error("Command doesn't support output type {}", outputType.toString()); + return 1; + } + String username = ns.getString("username"); final boolean useDbus = ns.getBoolean("dbus");