45 lines
1.2 KiB
PHP
45 lines
1.2 KiB
PHP
<?php
|
|
|
|
namespace Toolbox\Commands;
|
|
|
|
use Toolbox\Catalog;
|
|
use Toolbox\Lock;
|
|
|
|
final class CatalogCommand extends Command
|
|
{
|
|
public static function describe(): string
|
|
{
|
|
return 'Lista los paquetes y componentes disponibles';
|
|
}
|
|
|
|
public function run(array $args): int
|
|
{
|
|
$parsed = $this->parse($args);
|
|
$root = $this->root($parsed['options']);
|
|
$toolbox = $this->toolboxDir($parsed['options']);
|
|
|
|
$catalog = Catalog::fromRoot($toolbox);
|
|
$lock = Lock::load($root);
|
|
|
|
$rows = [['PAQUETE', 'COMPONENTE', 'ESTADO', 'DESCRIPCIÓN']];
|
|
foreach ($catalog->packages() as $package) {
|
|
$first = true;
|
|
foreach ($package->components() as $name => $component) {
|
|
$id = $package->name . ':' . $name;
|
|
$installed = $lock->has($id) ? 'instalado' : '-';
|
|
$rows[] = [
|
|
$first ? $package->name . ' (' . $package->version . ')' : '',
|
|
$name,
|
|
$installed,
|
|
$package->descriptionOf($name) ?? '',
|
|
];
|
|
$first = false;
|
|
}
|
|
}
|
|
|
|
$this->console->table($rows);
|
|
|
|
return 0;
|
|
}
|
|
}
|