refactor: console improvements — auto-discovery, centralized bootstrap, per-command help
- ConsoleApplication.discoverCommands() scans lib/Console/Commands/ automatically; adding a new command no longer requires editing bin/console - Command base class provides bootstrapApp(), bootstrapModuleApp(), requireBinScript() and projectRoot() helpers — eliminates fragile 4-level relative require_once paths - Per-command --help support via optional usage() method on Command - Docker-compose scheduler updated to use bin/console scheduler:run - Old bin scripts now emit deprecation hint to stderr when called directly Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -13,14 +13,27 @@ final class DeactivateCommand extends Command
|
||||
|
||||
public function description(): string
|
||||
{
|
||||
return 'Run a module\'s deactivation handler (--confirm or --dry-run)';
|
||||
return 'Run a module\'s deactivation handler';
|
||||
}
|
||||
|
||||
public function usage(): string
|
||||
{
|
||||
return <<<'USAGE'
|
||||
Usage: php bin/console module:deactivate <module-id> [options]
|
||||
|
||||
Options:
|
||||
--confirm Execute the deactivation handler
|
||||
--dry-run Validate the handler without executing
|
||||
|
||||
The module does not need to be in the enabled list.
|
||||
USAGE;
|
||||
}
|
||||
|
||||
public function execute(array $args, array $options): int
|
||||
{
|
||||
$moduleId = $args[0] ?? '';
|
||||
if ($moduleId === '') {
|
||||
fwrite(STDERR, "Usage: php bin/console module:deactivate <module-id> --confirm|--dry-run\n");
|
||||
fwrite(STDERR, $this->usage() . "\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -34,7 +47,7 @@ final class DeactivateCommand extends Command
|
||||
$argv[] = '--dry-run';
|
||||
}
|
||||
|
||||
require_once __DIR__ . '/../../../../bin/module-deactivate.php';
|
||||
$this->requireBinScript('module-deactivate.php');
|
||||
|
||||
return moduleDeactivateRun();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user