Skip to content

Commit

Permalink
Merge pull request #23 from 21TORR/debug
Browse files Browse the repository at this point in the history
  • Loading branch information
keichinger authored Jun 19, 2024
2 parents 8c58e53 + 457613d commit 8d8c094
Show file tree
Hide file tree
Showing 2 changed files with 69 additions and 95 deletions.
71 changes: 69 additions & 2 deletions src/Command/DebugCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,13 @@

use Symfony\Component\Console\Attribute\AsCommand;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Helper\TableCell;
use Symfony\Component\Console\Helper\TableCellStyle;
use Symfony\Component\Console\Helper\TableSeparator;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Torr\Cli\Console\Style\TorrStyle;
use Torr\TaskManager\Registry\TaskRegistry;
use Torr\TaskManager\Transport\TransportsHelper;

#[AsCommand("task-manager:debug")]
Expand All @@ -16,6 +20,7 @@ final class DebugCommand extends Command
*/
public function __construct (
private readonly TransportsHelper $transportsHelper,
private readonly TaskRegistry $taskRegistry,
)
{
parent::__construct();
Expand All @@ -29,9 +34,71 @@ protected function execute (InputInterface $input, OutputInterface $output) : in
$io = new TorrStyle($input, $output);
$io->title("Task Manager: Debug");

$io->section("Detected Queues");
$io->listing($this->transportsHelper->getOrderedQueueNames());
$this->listTasks($io);
$this->listQueues($io);

return self::SUCCESS;
}

/**
*/
private function listTasks (TorrStyle $io) : void
{
$io->section("Registered Tasks");
$rows = [];

foreach ($this->taskRegistry->getGroupedTasks() as $groupLabel => $tasks)
{
$first = true;

if (!empty($rows))
{
$rows[] = new TableSeparator();
}

foreach ($tasks as $task)
{
$row = [];
$metaData = $task->getMetaData();

if ($first)
{
$row[] = new TableCell($groupLabel, [
"rowspan" => \count($tasks),
"style" => new TableCellStyle([
"fg" => "blue",
]),
]);
$first = false;
}

$row[] = sprintf(
"<fg=yellow>%s</>",
$metaData->getKey(),
);
$row[] = $metaData->label;
$row[] = $task::class;
$rows[] = $row;
}
}

$io->table(
headers: [
"Group",
"Key",
"Name",
"Task Class",
],
rows: $rows,
);
}

/**
*
*/
private function listQueues (TorrStyle $io) : void
{
$io->section("Detected Queues");
$io->listing($this->transportsHelper->getOrderedQueueNames());
}
}
93 changes: 0 additions & 93 deletions src/Command/ListTasksCommand.php

This file was deleted.

0 comments on commit 8d8c094

Please sign in to comment.