Add --delete-account argument to completely delete an account

This commit is contained in:
AsamK 2021-05-03 00:03:31 +02:00
parent c79860b493
commit 0091c1cf26
3 changed files with 21 additions and 1 deletions

View file

@ -1,5 +1,6 @@
package org.asamk.signal.commands;
import net.sourceforge.argparse4j.impl.Arguments;
import net.sourceforge.argparse4j.inf.Namespace;
import net.sourceforge.argparse4j.inf.Subparser;
@ -14,13 +15,21 @@ public class UnregisterCommand implements LocalCommand {
@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) throws CommandException {
try {
m.unregister();
if (ns.getBoolean("delete_account")) {
m.deleteAccount();
} else {
m.unregister();
}
} catch (IOException e) {
e.printStackTrace();
throw new IOErrorException("Unregister error: " + e.getMessage());
}
}