Kelunik\AcmeClient\Commands\Setup::doExecute PHP Method

doExecute() public method

public doExecute ( League\CLImate\Argument\Manager $args )
$args League\CLImate\Argument\Manager
    public function doExecute(Manager $args)
    {
        $email = $args->get("email");
        (yield \Amp\resolve($this->checkEmail($email)));
        $server = \Kelunik\AcmeClient\resolveServer($args->get("server"));
        $keyFile = \Kelunik\AcmeClient\serverToKeyname($server);
        $path = "accounts/{$keyFile}.pem";
        $bits = 4096;
        $keyStore = new KeyStore(\Kelunik\AcmeClient\normalizePath($args->get("storage")));
        $this->climate->br();
        try {
            $keyPair = (yield $keyStore->get($path));
            $this->climate->whisper("    Using existing private key ...");
        } catch (KeyStoreException $e) {
            $this->climate->whisper("    No private key found, generating new one ...");
            $keyPair = (new OpenSSLKeyGenerator())->generate($bits);
            $keyPair = (yield $keyStore->put($path, $keyPair));
            $this->climate->whisper("    Generated new private key with {$bits} bits.");
        }
        $acme = $this->acmeFactory->build($server, $keyPair);
        $this->climate->whisper("    Registering with " . substr($server, 8) . " ...");
        /** @var Registration $registration */
        $registration = (yield $acme->register($email));
        $this->climate->info("    Registration successful. Contacts: " . implode(", ", $registration->getContact()));
        $this->climate->br();
        (yield new CoroutineResult(0));
    }