From 266cc067468dff8d20b5e9bcfc6c82f71f1e2c8b Mon Sep 17 00:00:00 2001 From: Niklas Keller Date: Wed, 23 Mar 2016 23:58:20 +0100 Subject: [PATCH] Improve output for various commands --- src/Commands/Issue.php | 13 ++++++++----- src/Commands/Revoke.php | 14 ++++++++++---- src/Commands/Setup.php | 13 ++++++++----- 3 files changed, 26 insertions(+), 14 deletions(-) diff --git a/src/Commands/Issue.php b/src/Commands/Issue.php index e87030c..2e2d20a 100644 --- a/src/Commands/Issue.php +++ b/src/Commands/Issue.php @@ -75,8 +75,9 @@ class Issue implements Command { throw new AcmeException("Account key not found, did you run 'bin/acme setup'?", 0, $e); } - $acme = new AcmeService(new AcmeClient($server, $keyPair)); + $this->climate->br(); + $acme = new AcmeService(new AcmeClient($server, $keyPair)); $promises = []; foreach ($domains as $i => $domain) { @@ -103,7 +104,8 @@ class Issue implements Command { $keyPair = (yield $keyStore->put($path, $keyPair)); } - $this->climate->info("Requesting certificate ..."); + $this->climate->br(); + $this->climate->whisper(" Requesting certificate ..."); $location = (yield $acme->requestCertificate($keyPair, $domains)); $certificates = (yield $acme->pollForCertificate($location)); @@ -112,7 +114,8 @@ class Issue implements Command { $certificateStore = new CertificateStore($path); yield $certificateStore->put($certificates); - $this->climate->info("Successfully issued certificate, see {$path}/" . reset($domains)); + $this->climate->info(" Successfully issued certificate."); + $this->climate->info(" See {$path}/" . reset($domains)); yield new CoroutineResult(0); } @@ -134,7 +137,7 @@ class Issue implements Command { $payload = $acme->generateHttp01Payload($keyPair, $token); - $this->climate->whisper("Providing payload at http://{$domain}/.well-known/acme-challenge/{$token}"); + $this->climate->whisper(" Providing payload at http://{$domain}/.well-known/acme-challenge/{$token}"); $challengeStore = new ChallengeStore($path); @@ -145,7 +148,7 @@ class Issue implements Command { yield $acme->answerChallenge($challenge->uri, $payload); yield $acme->pollForChallenge($location); - $this->climate->info("{$domain} is now authorized."); + $this->climate->comment(" {$domain} is now authorized."); yield $challengeStore->delete($token); } catch (Exception $e) { diff --git a/src/Commands/Revoke.php b/src/Commands/Revoke.php index 6b4d829..10bdc42 100644 --- a/src/Commands/Revoke.php +++ b/src/Commands/Revoke.php @@ -32,7 +32,8 @@ class Revoke implements Command { $keyPair = (yield $keyStore->get("accounts/{$keyFile}.pem")); $acme = new AcmeService(new AcmeClient($server, $keyPair), $keyPair); - $this->climate->info("Revoking certificate ..."); + $this->climate->br(); + $this->climate->whisper(" Revoking certificate ..."); $path = \Kelunik\AcmeClient\normalizePath($args->get("storage")) . "/certs/" . $keyFile . "/" . $args->get("name") . "/cert.pem"; @@ -44,12 +45,17 @@ class Revoke implements Command { } if ($cert->getValidTo() < time()) { - $this->climate->info("Certificate did already expire, no need to revoke it."); + $this->climate->comment(" Certificate did already expire, no need to revoke it."); } - $this->climate->info("Certificate was valid for: " . implode(", ", $cert->getNames())); + $names = $cert->getNames(); + $this->climate->whisper(" Certificate was valid for " . count($names) . " domains."); + $this->climate->whisper(" - " . implode(PHP_EOL . " - ", $names) . PHP_EOL); + yield $acme->revokeCertificate($pem); - $this->climate->info("Certificate has been revoked."); + + $this->climate->br(); + $this->climate->info(" Certificate has been revoked."); yield (new CertificateStore(\Kelunik\AcmeClient\normalizePath($args->get("storage")). "/certs/" . $keyFile))->delete($args->get("name")); diff --git a/src/Commands/Setup.php b/src/Commands/Setup.php index 0b1c14d..11017d3 100644 --- a/src/Commands/Setup.php +++ b/src/Commands/Setup.php @@ -39,25 +39,28 @@ class Setup implements Command { $keyStore = new KeyStore(\Kelunik\AcmeClient\normalizePath($args->get("storage"))); + $this->climate->br(); + try { $keyPair = (yield $keyStore->get($path)); - $this->climate->info("Existing private key successfully loaded."); + $this->climate->whisper(" Using existing private key ..."); } catch (KeyStoreException $e) { - $this->climate->info("No private key found, generating new one ..."); + $this->climate->whisper(" No private key found, generating new one ..."); $keyPair = (new OpenSSLKeyGenerator)->generate($bits); $keyPair = (yield $keyStore->put($path, $keyPair)); - $this->climate->info("Generated new private key with {$bits} bits."); + $this->climate->whisper(" Generated new private key with {$bits} bits."); } $acme = new AcmeService(new AcmeClient($server, $keyPair), $keyPair); - $this->climate->info("Registering with ACME server " . substr($server, 8) . " ..."); + $this->climate->whisper(" Registering with " . substr($server, 8) . " ..."); /** @var Registration $registration */ $registration = (yield $acme->register($email)); - $this->climate->whisper("Registration successful with the following contact information: " . implode(", ", $registration->getContact())); + $this->climate->info(" Registration successful. Contacts: " . implode(", ", $registration->getContact())); + $this->climate->br(); yield new CoroutineResult(0); }