forked from fa/breadcrumb-the-shire
- 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>
55 lines
1.3 KiB
PHP
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();
|
|
}
|
|
}
|