Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove :list command and add the content to :debug [req #21] #23

Merged
merged 1 commit into from
Jun 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.

Loading