]> nmode's Git Repositories - signal-cli/blobdiff - src/main/java/org/asamk/signal/commands/RemoveDeviceCommand.java
Refactor dbus client mode to improve maintainability
[signal-cli] / src / main / java / org / asamk / signal / commands / RemoveDeviceCommand.java
index a4d4ffeae60cb708335089155f943aa97e76eac5..d67cc5eafda8e126363268cb500ab1a177daddf5 100644 (file)
@@ -10,12 +10,15 @@ import org.asamk.signal.manager.Manager;
 
 import java.io.IOException;
 
 
 import java.io.IOException;
 
-public class RemoveDeviceCommand implements LocalCommand {
+public class RemoveDeviceCommand implements JsonRpcLocalCommand {
 
 
-    public RemoveDeviceCommand(final OutputWriter outputWriter) {
+    @Override
+    public String getName() {
+        return "removeDevice";
     }
 
     }
 
-    public static void attachToSubparser(final Subparser subparser) {
+    @Override
+    public void attachToSubparser(final Subparser subparser) {
         subparser.help("Remove a linked device.");
         subparser.addArgument("-d", "--device-id", "--deviceId")
                 .type(int.class)
         subparser.help("Remove a linked device.");
         subparser.addArgument("-d", "--device-id", "--deviceId")
                 .type(int.class)
@@ -24,12 +27,14 @@ public class RemoveDeviceCommand implements LocalCommand {
     }
 
     @Override
     }
 
     @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 {
             int deviceId = ns.getInt("device-id");
             m.removeLinkedDevices(deviceId);
         } catch (IOException e) {
         try {
             int deviceId = ns.getInt("device-id");
             m.removeLinkedDevices(deviceId);
         } catch (IOException e) {
-            throw new IOErrorException("Error while removing device: " + e.getMessage());
+            throw new IOErrorException("Error while removing device: " + e.getMessage(), e);
         }
     }
 }
         }
     }
 }