Commit 6fb496f5 authored by Jon Pugh's avatar Jon Pugh

New verbose task output! Clearly blocks out beginning and end of tasks with pretty colors!

parent 1d3e6b5a
......@@ -2,6 +2,7 @@
namespace Aegir\Provision\Console;
use Aegir\Provision\Provision;
use Drupal\Console\Core\Style\DrupalStyle;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\BufferedOutput;
......@@ -30,6 +31,50 @@ class ProvisionStyle extends DrupalStyle {
parent::__construct($input, $output);
}
public function taskInfoBlock($task_id, $op, $status = 'none') {
switch ($op) {
case 'started':
default:
$bg = 'blue';
$fg = 'white';
$icon = '▷';
$op = ucfirst($op);
break;
case 'completed':
$bg = 'black';
$fg = 'green';
$icon = '🏁';
$op = ucfirst($op);
break;
case 'failed':
$bg = 'black';
$fg = 'red';
$icon = '🔥';
$op = ucfirst($op);
break;
}
$app_name = Provision::APPLICATION_FUN_NAME;
$message = "{$app_name} {$icon} {$op}";
$timestamp = date('r');
$message_suffix = "{$timestamp}{$task_id}";
$spaces = $this::MAX_LINE_LENGTH - strlen($message . $message_suffix) - 2;
$message .= str_repeat(' ', $spaces) . $message_suffix;
$this->autoPrependBlock();
$this->block(
$message,
NULL,
"bg=$bg;fg=$fg",
' ',
TRUE
);
}
public function commandBlock($message) {
$this->autoPrependBlock();
......
......@@ -44,7 +44,7 @@ class ProvisionCollection extends Collection {
$task = $this->getConfig()->get($name);
if ($this->getProvision()->getOutput()->isVerbose()) {
$this->getProvision()->io()->customLite('STARTED ' . $name, '○');
$this->getProvision()->io()->taskInfoBlock($name, 'start');
}
// Show starting message.
......@@ -94,15 +94,16 @@ class ProvisionCollection extends Collection {
$failure_message .= ' <fg=red>FAILED</> in <fg=yellow>' . number_format($timer->elapsed(), 2) . 's</>';
if ($this->getProvision()->getOutput()->isVerbose()) {
$this->getProvision()->io()->errorLite('<options=bold>FAILED </> in' . $name);
$this->getProvision()->io()->taskInfoBlock($name, 'failed');
}
else {
$this->getProvision()->io()->errorLite($failure_message);
// If task failed and there is getMessage, it is the exception message.
if (!empty($result->getMessage())) {
$this->getProvision()->io()->customLite($result->getMessage(), ' - ');
}
$this->getProvision()->io()->errorLite($failure_message);
// If task failed and there is getMessage, it is the exception message.
if (!empty($result->getMessage())) {
$this->getProvision()->io()->customLite($result->getMessage(), ' - ');
}
$this->fail();
return $result;
}
......@@ -122,11 +123,12 @@ class ProvisionCollection extends Collection {
$success_message .= ' <fg=yellow>' . number_format($timer->elapsed(), 2) . 's</>';
$this->getProvision()->io()->successLite($success_message);
if ($this->getProvision()->getOutput()->isVerbose()) {
$this->getProvision()->io()->successLite($success_message);
}
else {
$this->getProvision()->io()->successLite($success_message);
if ($this->getProvision()->getOutput()->isVerbose()) {
$this->getProvision()->io()->taskInfoBlock($name, 'completed');
}
}
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment