]> nmode's Git Repositories - signal-cli/blobdiff - src/main/java/org/asamk/signal/commands/RegisterCommand.java
Print stack trace of exception causes in verbose mode
[signal-cli] / src / main / java / org / asamk / signal / commands / RegisterCommand.java
index a4c613afc09a0e78c525eebf8665aeb21203220f..96530889a10f902b87bfc156af18b68621a5e27c 100644 (file)
@@ -14,10 +14,16 @@ import java.io.IOException;
 
 public class RegisterCommand implements RegistrationCommand {
 
+    @Override
+    public String getName() {
+        return "register";
+    }
+
     @Override
     public void attachToSubparser(final Subparser subparser) {
+        subparser.help("Register a phone number with SMS or voice verification.");
         subparser.addArgument("-v", "--voice")
-                .help("The verification should be done over voice, not sms.")
+                .help("The verification should be done over voice, not SMS.")
                 .action(Arguments.storeTrue());
         subparser.addArgument("--captcha")
                 .help("The captcha token, required if registration failed with a captcha required error.");
@@ -26,7 +32,8 @@ public class RegisterCommand implements RegistrationCommand {
     @Override
     public void handleCommand(final Namespace ns, final RegistrationManager m) throws CommandException {
         final boolean voiceVerification = ns.getBoolean("voice");
-        final var captcha = ns.getString("captcha");
+        final var captchaString = ns.getString("captcha");
+        final var captcha = captchaString == null ? null : captchaString.replace("signalcaptcha://", "");
 
         try {
             m.register(voiceVerification, captcha);
@@ -42,7 +49,7 @@ public class RegisterCommand implements RegistrationCommand {
             }
             throw new UserErrorException(message);
         } catch (IOException e) {
-            throw new IOErrorException("Request verify error: " + e.getMessage());
+            throw new IOErrorException("Request verify error: " + e.getMessage(), e);
         }
     }
 }