Skip to content

Commit

Permalink
Add info about skipped tasks
Browse files Browse the repository at this point in the history
  • Loading branch information
antonmedv committed Nov 21, 2021
1 parent 465aed4 commit 333baff
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
8 changes: 6 additions & 2 deletions src/Command/MainCommand.php
Expand Up @@ -113,9 +113,10 @@ protected function execute(Input $input, Output $output): int
$this->deployer->scriptManager->setHooksEnabled(!$input->getOption('no-hooks'));
$startFrom = $input->getOption('start-from');
if ($startFrom && !$this->deployer->tasks->has($startFrom)) {
throw new Exception("Task ${startFrom} does not exist.");
throw new Exception("Task $startFrom does not exist.");
}
$tasks = $this->deployer->scriptManager->getTasks($this->getName(), $startFrom);
$skippedTasks = [];
$tasks = $this->deployer->scriptManager->getTasks($this->getName(), $startFrom, $skippedTasks);

if (empty($tasks)) {
throw new Exception('No task will be executed, because the selected hosts do not meet the conditions of the tasks');
Expand All @@ -126,6 +127,9 @@ protected function execute(Input $input, Output $output): int
$this->validateConfig();
$this->deployer->master->connect($hosts);
$this->deployer->server->start();
foreach ($skippedTasks as $taskName) {
$output->writeln("<fg=yellow;options=bold>skip</> $taskName");
}
}
$exitCode = $this->deployer->master->run($tasks, $hosts, $plan);

Expand Down
4 changes: 2 additions & 2 deletions src/Task/ScriptManager.php
Expand Up @@ -14,7 +14,6 @@ class ScriptManager
{
private $tasks;
private $hooksEnabled = true;
private $startFrom = null;
private $visitedTasks = [];

public function __construct(TaskCollection $tasks)
Expand All @@ -27,7 +26,7 @@ public function __construct(TaskCollection $tasks)
*
* @return Task[]
*/
public function getTasks(string $name, ?string $startFrom = null): array
public function getTasks(string $name, ?string $startFrom = null, array &$skipped = []): array
{
$tasks = [];
$this->visitedTasks = [];
Expand All @@ -42,6 +41,7 @@ public function getTasks(string $name, ?string $startFrom = null): array
if ($task->getName() === $startFrom) {
$skip = false;
} else {
$skipped[] = $task->getName();
continue;
}
}
Expand Down

0 comments on commit 333baff

Please sign in to comment.