45 lines
1.3 KiB
PHP
45 lines
1.3 KiB
PHP
<?php
|
|
|
|
namespace Toolbox\Commands;
|
|
|
|
use Toolbox\Installer;
|
|
use Toolbox\ToolboxException;
|
|
|
|
final class RemoveCommand extends Command
|
|
{
|
|
public static function describe(): string
|
|
{
|
|
return 'Quita componentes instalados (sólo sus archivos)';
|
|
}
|
|
|
|
public function run(array $args): int
|
|
{
|
|
$parsed = $this->parse($args);
|
|
|
|
if ($parsed['args'] === []) {
|
|
$this->console->error('Indica al menos un componente (paquete:componente).');
|
|
return 1;
|
|
}
|
|
|
|
$root = $this->root($parsed['options']);
|
|
$toolbox = $this->toolboxDir($parsed['options']);
|
|
$installer = new Installer($root, $toolbox, $this->console, $this->rootCore($parsed['options'], $root));
|
|
|
|
try {
|
|
$result = $installer->remove($parsed['args'], $this->behaviorOptions($parsed['options']));
|
|
} catch (ToolboxException $e) {
|
|
$this->console->error($e->getMessage());
|
|
return 1;
|
|
}
|
|
|
|
foreach ($result['removed'] as $id) {
|
|
$this->console->ok('quitado ' . $id);
|
|
}
|
|
foreach ($result['aborted'] as $aborted) {
|
|
$this->console->error('abortado (edición local): ' . $aborted);
|
|
}
|
|
|
|
return $result['aborted'] === [] ? 0 : 1;
|
|
}
|
|
}
|