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:
kj
2026-10-06 15:14:33 -03:00
parent 5eb019726a
commit c2931245bb
7 changed files with 257 additions and 62 deletions
+16
View File
@@ -262,3 +262,19 @@ Harness::it('el catálogo describe cada componente con su texto propio o heredad
rrmdir($toolbox);
rrmdir($proj);
});
Harness::it('un comando del proyecto sin describe() no carga (interfaz estricta)', function () {
$proj = tmpdir('proj');
mkdir($proj . '/src/Commands', 0777, true);
write_file($proj . '/autoload.php', "<?php\nspl_autoload_register(function (string \$c): void {\n \$f = \$c === 'Commands\\\\SinDoc' ? ROOT_CORE . '/Commands/SinDoc.php' : null;\n if (\$f !== null && is_file(\$f)) { require \$f; }\n});\ndefine('ROOT_CORE', __DIR__ . '/src');\ndefine('ROOT_DIR', __DIR__);\n");
write_file($proj . '/src/Commands/SinDoc.php', "<?php\nnamespace Commands;\nclass SinDoc implements \\Interfaces\\CommandInterface { public function run(): void {} }\n");
write_file($proj . '/src/Interfaces/CommandInterface.php', "<?php\nnamespace Interfaces;\ninterface CommandInterface { public function run(): void; public static function describe(): string; }\n");
$out = [];
$code = 0;
exec('cd ' . escapeshellarg($proj) . ' && php -r \'require "autoload.php"; class_exists("Commands\\\\SinDoc") ? print("loaded") : print("missing");\' 2>&1', $out, $code);
ok($code !== 0 || str_contains(implode('', $out), 'Fatal'), 'la carga de un comando sin describe produce error fatal');
rrmdir($proj);
});