mirror of
https://github.com/AsamK/signal-cli
synced 2025-08-29 10:30:38 +00:00
43 lines
1.4 KiB
Java
43 lines
1.4 KiB
Java
package org.asamk.signal.commands;
|
|
|
|
import net.sourceforge.argparse4j.impl.Arguments;
|
|
import net.sourceforge.argparse4j.inf.Namespace;
|
|
import net.sourceforge.argparse4j.inf.Subparser;
|
|
|
|
import org.asamk.signal.OutputWriter;
|
|
import org.asamk.signal.commands.exceptions.CommandException;
|
|
import org.asamk.signal.commands.exceptions.IOErrorException;
|
|
import org.asamk.signal.manager.Manager;
|
|
|
|
import java.io.IOException;
|
|
|
|
public class UnregisterCommand implements LocalCommand {
|
|
|
|
@Override
|
|
public String getName() {
|
|
return "unregister";
|
|
}
|
|
|
|
@Override
|
|
public void attachToSubparser(final Subparser subparser) {
|
|
subparser.help("Unregister the current device from the signal server.");
|
|
subparser.addArgument("--delete-account")
|
|
.help("Delete account completely from server. CAUTION: Only do this if you won't use this number again!")
|
|
.action(Arguments.storeTrue());
|
|
}
|
|
|
|
@Override
|
|
public void handleCommand(
|
|
final Namespace ns, final Manager m, final OutputWriter outputWriter
|
|
) throws CommandException {
|
|
try {
|
|
if (ns.getBoolean("delete-account")) {
|
|
m.deleteAccount();
|
|
} else {
|
|
m.unregister();
|
|
}
|
|
} catch (IOException e) {
|
|
throw new IOErrorException("Unregister error: " + e.getMessage(), e);
|
|
}
|
|
}
|
|
}
|