feat(cli): pure alias-based dispatcher in project bin; Commands\Toolbox entry point; describe() required on CommandInterface
BREAKING: project commands implementing CommandInterface must define static describe(): string (intentional, forces documentation).
This commit is contained in:
@@ -10,6 +10,11 @@ use PDO;
|
||||
|
||||
class Migration implements CommandInterface
|
||||
{
|
||||
public static function describe(): string
|
||||
{
|
||||
return 'Migraciones de base de datos (create, migrate, rollback, fresh, clear)';
|
||||
}
|
||||
|
||||
private const MIGRATIONS_PATH = ROOT_DIR . '/migrations/';
|
||||
private string $migratonsDatabaseFile;
|
||||
private PDO $db;
|
||||
|
||||
@@ -0,0 +1,39 @@
|
||||
<?php
|
||||
|
||||
namespace Commands;
|
||||
|
||||
use Interfaces\CommandInterface;
|
||||
use Toolbox\Cli;
|
||||
|
||||
/**
|
||||
* Entry point del gestor de addons dentro del proyecto: el bin `duckbrain`
|
||||
* despacha aquí todo alias del motor (add, remove, update, list, doctor,
|
||||
* catalog, adopt, help y variantes de versión/usage). Vive en el namespace
|
||||
* Commands del proyecto para que el binario siga siendo un despachador
|
||||
* genérico: no conoce la lista de comandos de nadie más que de los propios.
|
||||
*/
|
||||
class Toolbox implements CommandInterface
|
||||
{
|
||||
public static function describe(): string
|
||||
{
|
||||
return 'Gestor de addons del proyecto (motor duckbrain-toolbox)';
|
||||
}
|
||||
|
||||
/**
|
||||
* @return list<string>
|
||||
*/
|
||||
public static function aliases(): array
|
||||
{
|
||||
return [
|
||||
'add', 'remove', 'update', 'list', 'doctor', 'catalog', 'adopt',
|
||||
'help', '--help', '-h', '--version', '-V',
|
||||
];
|
||||
}
|
||||
|
||||
public function run(): void
|
||||
{
|
||||
$args = func_get_args();
|
||||
|
||||
exit((new Cli())->run(array_merge(['duckbrain'], array_map('strval', $args))));
|
||||
}
|
||||
}
|
||||
@@ -10,4 +10,10 @@ interface CommandInterface
|
||||
* @return void
|
||||
*/
|
||||
public function run(): void;
|
||||
|
||||
/**
|
||||
* Descripción de una línea del comando, obligatoria: fuerza a documentar
|
||||
* cada comando del proyecto para que sea visible en la superficie.
|
||||
*/
|
||||
public static function describe(): string;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user