mirror of
https://github.com/AsamK/signal-cli
synced 2025-08-29 10:30:38 +00:00
Split commands into separate classes
This commit is contained in:
parent
2ab70edc68
commit
f60a10eb6e
30 changed files with 1121 additions and 742 deletions
29
src/main/java/org/asamk/signal/commands/RegisterCommand.java
Normal file
29
src/main/java/org/asamk/signal/commands/RegisterCommand.java
Normal file
|
@ -0,0 +1,29 @@
|
|||
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.manager.Manager;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
public class RegisterCommand implements LocalCommand {
|
||||
|
||||
@Override
|
||||
public void attachToSubparser(final Subparser subparser) {
|
||||
subparser.addArgument("-v", "--voice")
|
||||
.help("The verification should be done over voice, not sms.")
|
||||
.action(Arguments.storeTrue());
|
||||
}
|
||||
|
||||
@Override
|
||||
public int handleCommand(final Namespace ns, final Manager m) {
|
||||
try {
|
||||
m.register(ns.getBoolean("voice"));
|
||||
return 0;
|
||||
} catch (IOException e) {
|
||||
System.err.println("Request verify error: " + e.getMessage());
|
||||
return 3;
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue