Initial Version

This commit is contained in:
root
2025-12-21 10:09:54 -05:00
commit 4ae6befc7b
422 changed files with 47225 additions and 0 deletions

View File

@@ -0,0 +1,86 @@
<?php
declare(strict_types=1);
namespace KTXC\Console;
use KTXC\Module\ModuleManager;
use Symfony\Component\Console\Attribute\AsCommand;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Style\SymfonyStyle;
/**
* Module List Command
*
* Lists all modules with their status and version information.
*/
#[AsCommand(
name: 'module:list',
description: 'List all modules with their status and versions',
)]
class ModuleListCommand extends Command
{
public function __construct(
private readonly ModuleManager $moduleManager
) {
parent::__construct();
}
protected function configure(): void
{
$this
->addOption('all', 'a', InputOption::VALUE_NONE, 'Show all modules including disabled ones')
->setHelp('This command lists all installed modules with their status and version information.')
;
}
protected function execute(InputInterface $input, OutputInterface $output): int
{
$io = new SymfonyStyle($input, $output);
$showAll = $input->getOption('all');
$io->title('Installed Modules');
try {
$modules = $this->moduleManager->list(
installedOnly: true,
enabledOnly: !$showAll
);
if (count($modules) === 0) {
$io->warning('No modules found.');
return Command::SUCCESS;
}
$rows = [];
foreach ($modules as $module) {
$status = $module->enabled() ? '<fg=green>Enabled</>' : '<fg=yellow>Disabled</>';
$upgrade = $module->needsUpgrade() ? '<fg=red>Yes</>' : '';
$rows[] = [
$module->handle(),
$module->version(),
$status,
$upgrade,
$module->namespace() ?? 'N/A',
];
}
$io->table(
['Handle', 'Version', 'Status', 'Needs Upgrade', 'Namespace'],
$rows
);
$io->success(sprintf('Found %d module(s).', count($modules)));
return Command::SUCCESS;
} catch (\Throwable $e) {
$io->error('Failed to list modules: ' . $e->getMessage());
return Command::FAILURE;
}
}
}