import org.asamk.signal.commands.exceptions.CommandException;
import org.asamk.signal.commands.exceptions.IOErrorException;
+import org.asamk.signal.commands.exceptions.UserErrorException;
import org.asamk.signal.manager.Manager;
+import org.asamk.signal.manager.api.NotPrimaryDeviceException;
import org.asamk.signal.output.OutputWriter;
import java.io.IOException;
public void attachToSubparser(final Subparser subparser) {
subparser.help("Remove a linked device.");
subparser.addArgument("-d", "--device-id", "--deviceId")
- .type(long.class)
+ .type(int.class)
.required(true)
.help("Specify the device you want to remove. Use listDevices to see the deviceIds.");
}
final Namespace ns, final Manager m, final OutputWriter outputWriter
) throws CommandException {
try {
- final var deviceId = ns.getLong("device-id");
+ final var deviceId = ns.getInt("device-id");
m.removeLinkedDevices(deviceId);
+ } catch (NotPrimaryDeviceException e) {
+ throw new UserErrorException("This command doesn't work on linked devices.");
} catch (IOException e) {
throw new IOErrorException("Error while removing device: " + e.getMessage(), e);
}