first commit.
This commit is contained in:
@@ -0,0 +1,40 @@
|
||||
#!/usr/bin/env php
|
||||
<?php
|
||||
|
||||
// CLI del proyecto Duckbrain. Requiere el autoloader del core (proyecto ya
|
||||
// armado). Delega en el motor `Toolbox\` si el componente opcional
|
||||
// `commands:toolbox` está instalado; en caso contrario, sólo ofrece los
|
||||
// comandos propios del proyecto (p. ej. migraciones).
|
||||
require_once('./autoload.php');
|
||||
|
||||
$command = $argv[1] ?? null;
|
||||
|
||||
$toolboxCommands = [
|
||||
'add', 'remove', 'update', 'list', 'doctor', 'catalog', 'adopt',
|
||||
'help', '--help', '-h', '--version', '-V',
|
||||
];
|
||||
|
||||
if ($command === null || in_array($command, $toolboxCommands, true)) {
|
||||
if (!class_exists('Toolbox\\Cli')) {
|
||||
fwrite(STDERR, "El componente 'commands:toolbox' no está instalado.\n");
|
||||
fwrite(STDERR, "Añádelo con el instalador global: duckbrain add commands:toolbox\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
exit((new Toolbox\Cli())->run($argv));
|
||||
}
|
||||
|
||||
// Comandos propios del proyecto, despachados desde ROOT_CORE/Commands.
|
||||
$coreCommand = 'Commands\\' . ucfirst($command);
|
||||
|
||||
if (!class_exists($coreCommand) && !file_exists(ROOT_CORE . '/Commands/' . ucfirst($command) . '.php')) {
|
||||
exit("Invalid command.\n");
|
||||
}
|
||||
|
||||
$cli = new $coreCommand();
|
||||
|
||||
if ($cli instanceof Interfaces\CommandInterface) {
|
||||
call_user_func_array([$cli, 'run'], array_slice($argv, 2));
|
||||
} else {
|
||||
exit("Invalid command.\n");
|
||||
}
|
||||
Reference in New Issue
Block a user