first commit.
This commit is contained in:
@@ -0,0 +1,44 @@
|
||||
<?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,
|
||||
$first ? $package->description : '',
|
||||
];
|
||||
$first = false;
|
||||
}
|
||||
}
|
||||
|
||||
$this->console->table($rows);
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user