1 package org
.asamk
.signal
.commands
;
3 import net
.sourceforge
.argparse4j
.impl
.Arguments
;
4 import net
.sourceforge
.argparse4j
.inf
.Namespace
;
5 import net
.sourceforge
.argparse4j
.inf
.Subparser
;
7 import org
.asamk
.signal
.manager
.Manager
;
8 import org
.whispersystems
.signalservice
.api
.push
.exceptions
.CaptchaRequiredException
;
10 import java
.io
.IOException
;
12 public class RegisterCommand
implements LocalCommand
{
15 public void attachToSubparser(final Subparser subparser
) {
16 subparser
.addArgument("-v", "--voice")
17 .help("The verification should be done over voice, not sms.")
18 .action(Arguments
.storeTrue());
19 subparser
.addArgument("--captcha")
20 .help("The captcha token, required if registration failed with a captcha required error.");
24 public int handleCommand(final Namespace ns
, final Manager m
) {
26 final boolean voiceVerification
= ns
.getBoolean("voice");
27 final String captcha
= ns
.getString("captcha");
28 m
.register(voiceVerification
, captcha
);
30 } catch (CaptchaRequiredException e
) {
31 System
.err
.println("Captcha invalid or required for verification (" + e
.getMessage() + ")");
33 } catch (IOException e
) {
34 System
.err
.println("Request verify error: " + e
.getMessage());