Files
breadcrumb-the-shire/lib/Console/Commands/Module/DeactivateCommand.php
fs ba1186c525 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>
2026-03-19 19:16:36 +01:00

55 lines
1.3 KiB
PHP

<?php
namespace MintyPHP\Console\Commands\Module;
use MintyPHP\Console\Command;
final class DeactivateCommand extends Command
{
public function name(): string
{
return 'module:deactivate';
}
public function description(): string
{
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, $this->usage() . "\n");
return 1;
}
// Rebuild global argv for the underlying script
global $argv;
$argv = ['module-deactivate.php', $moduleId];
if ($options['confirm'] ?? false) {
$argv[] = '--confirm';
}
if ($options['dry-run'] ?? false) {
$argv[] = '--dry-run';
}
$this->requireBinScript('module-deactivate.php');
return moduleDeactivateRun();
}
}