Skip to content

Commit

Permalink
[TASK] Add option to disable spinner animation for a task
Browse files Browse the repository at this point in the history
  • Loading branch information
ochorocho committed Dec 17, 2023
1 parent 11cef74 commit fe62772
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/Executor/Master.php
Original file line number Diff line number Diff line change
Expand Up @@ -201,9 +201,9 @@ private function runTask(Task $task, array $hosts): int
}
});

$this->server->loop->addPeriodicTimer(0.03, function ($timer) use (&$processes, $callback) {
$this->server->loop->addPeriodicTimer(0.03, function ($timer) use (&$processes, $callback, $task) {
$this->gatherOutput($processes, $callback);
if ($this->output->isDecorated() && !getenv('CI')) {
if ($this->output->isDecorated() && !getenv('CI') && $task->hasSpinner()) {
$this->output->write(spinner());
}
if ($this->allFinished($processes)) {
Expand Down
15 changes: 15 additions & 0 deletions src/Task/Task.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,10 @@ class Task
* @var bool
*/
private $verbose = false;
/**
* @var bool
*/
private $spinner = true;
/**
* @var bool
*/
Expand Down Expand Up @@ -254,6 +258,17 @@ public function verbose(bool $verbose = true): self
return $this;
}

public function hasSpinner(): bool
{
return $this->spinner;
}

public function spinner(bool $enabled = true): self
{
$this->spinner = $enabled;
return $this;
}

public function isEnabled(): bool
{
return $this->enabled;
Expand Down

0 comments on commit fe62772

Please sign in to comment.