Skip to content

Commit

Permalink
Improve output formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
imbrish committed Nov 17, 2017
1 parent 0c29c20 commit 368086d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 9 deletions.
8 changes: 4 additions & 4 deletions bin/letsencrypt
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ foreach ($config['certificates'] as $certificate) {
// issue new certificate

if (Command::$result == 0) {
$climate->out('Certificate still valid for domains: ' . implode(', ', $domainNames) . '.');
$climate->info('Certificate still valid for domains: ' . implode(', ', $domainNames) . '.');
}
else {
Command::exec('acme', [
Expand All @@ -226,7 +226,7 @@ foreach ($config['certificates'] as $certificate) {

$notifications[] = 'Certificate issued for domains: ' . implode(', ', $domainNames) . '.';

$climate->out(end($notifications));
$climate->info(end($notifications));
}

// install certificate in cpanel for corresponding domains
Expand Down Expand Up @@ -273,13 +273,13 @@ foreach ($config['certificates'] as $certificate) {
if ($installDomains) {
$notifications[] = 'Certificate installed for domains: ' . implode(', ', $installDomains) . '.';

$climate->out(end($notifications));
$climate->info(end($notifications));
}
}

if ($notifications) {
notify('New certificates have been issued', implode(PHP_EOL, $notifications));
}
else {
$climate->out('No certificates were issued.');
$climate->info('No certificates were issued.');
}
8 changes: 3 additions & 5 deletions src/Command.php
Original file line number Diff line number Diff line change
Expand Up @@ -134,14 +134,12 @@ public function __exec()

// save and show command output together with error log
static::$output = implode(PHP_EOL, $output) . (trim($error_log) ? $error_log : '');
static::$output = preg_replace('/^[\t ]+/', '', trim(static::$output));

// ensure that output ends with a newline
if (trim(static::$output) && ! preg_match('/(\n|\r\n)[\t ]*$/', static::$output)) {
static::$output .= PHP_EOL;
if (static::$output) {
echo static::$output . PHP_EOL;
}

echo static::$output;

// save and return last result code
static::$result = $code;

Expand Down

0 comments on commit 368086d

Please sign in to comment.