- private static ArgumentParser buildBaseArgumentParser() {
- ArgumentParser parser = ArgumentParsers.newFor("signal-cli")
- .build()
- .defaultHelp(true)
- .description("Commandline interface for Signal.")
- .version(BaseConfig.PROJECT_NAME + " " + BaseConfig.PROJECT_VERSION);
-
- parser.addArgument("-v", "--version").help("Show package version.").action(Arguments.version());
- parser.addArgument("--verbose")
- .help("Raise log level and include lib signal logs.")
- .action(Arguments.storeTrue());
- parser.addArgument("--config")
- .help("Set the path, where to store the config (Default: $XDG_DATA_HOME/signal-cli , $HOME/.local/share/signal-cli).");
-
- MutuallyExclusiveGroup mut = parser.addMutuallyExclusiveGroup();
- mut.addArgument("-u", "--username").help("Specify your phone number, that will be used for verification.");
- mut.addArgument("--dbus").help("Make request via user dbus.").action(Arguments.storeTrue());
- mut.addArgument("--dbus-system").help("Make request via system dbus.").action(Arguments.storeTrue());
-
- parser.addArgument("-o", "--output")
- .help("Choose to output in plain text or JSON")
- .choices("plain-text", "json")
- .setDefault("plain-text");
-
- return parser;
+ private static int getStatusForError(final CommandException e) {
+ if (e instanceof UserErrorException) {
+ return 1;
+ } else if (e instanceof UnexpectedErrorException) {
+ return 2;
+ } else if (e instanceof IOErrorException) {
+ return 3;
+ } else if (e instanceof UntrustedKeyErrorException) {
+ return 4;
+ } else {
+ return 2;
+ }