X-Git-Url: https://git.nmode.ca/signal-cli/blobdiff_plain/5d8d0dcad688c493562f055627158d7300086424..7c9fd9d0fb7b303e8194a6de9aed852c488afc25:/src/main/java/org/asamk/signal/commands/AddDeviceCommand.java diff --git a/src/main/java/org/asamk/signal/commands/AddDeviceCommand.java b/src/main/java/org/asamk/signal/commands/AddDeviceCommand.java index 31b3c7ef..e609ec1e 100644 --- a/src/main/java/org/asamk/signal/commands/AddDeviceCommand.java +++ b/src/main/java/org/asamk/signal/commands/AddDeviceCommand.java @@ -21,28 +21,33 @@ public class AddDeviceCommand implements JsonRpcLocalCommand { private final static Logger logger = LoggerFactory.getLogger(AddDeviceCommand.class); - public static void attachToSubparser(final Subparser subparser) { + @Override + public String getName() { + return "addDevice"; + } + + @Override + public void attachToSubparser(final Subparser subparser) { subparser.help("Link another device to this device. Only works, if this is the master device."); subparser.addArgument("--uri") .required(true) .help("Specify the uri contained in the QR code shown by the new device."); } - public AddDeviceCommand(final OutputWriter outputWriter) { - } - @Override - public void handleCommand(final Namespace ns, final Manager m) throws CommandException { + public void handleCommand( + final Namespace ns, final Manager m, final OutputWriter outputWriter + ) throws CommandException { try { m.addDeviceLink(new URI(ns.getString("uri"))); } catch (IOException e) { logger.error("Add device link failed", e); - throw new IOErrorException("Add device link failed"); + throw new IOErrorException("Add device link failed", e); } catch (URISyntaxException e) { throw new UserErrorException("Device link uri has invalid format: " + e.getMessage()); } catch (InvalidKeyException e) { logger.error("Add device link failed", e); - throw new UnexpectedErrorException("Add device link failed."); + throw new UnexpectedErrorException("Add device link failed.", e); } } }