- remove legacy bin/module-*.php and bin/doctor.php entry scripts - move module/doctor execution into class-based runners under lib/Console - add stable JSON output for doctor and module:sync - introduce bin/dev for init/up/down/logs/console/qa workflow - update DI wiring, phpstan scan config, tests, and docs to new CLI contract
50 lines
1.2 KiB
PHP
50 lines
1.2 KiB
PHP
<?php
|
|
|
|
namespace MintyPHP\Console\Commands\Module;
|
|
|
|
final class DeactivateCommand extends AbstractModuleCommand
|
|
{
|
|
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;
|
|
}
|
|
|
|
$result = $this->moduleRunner()->deactivate(
|
|
$moduleId,
|
|
(bool) ($options['confirm'] ?? false),
|
|
(bool) ($options['dry-run'] ?? false)
|
|
);
|
|
|
|
$stream = $result['exit_code'] === 0 ? STDOUT : STDERR;
|
|
fwrite($stream, $result['message'] . PHP_EOL);
|
|
|
|
return (int) $result['exit_code'];
|
|
}
|
|
}
|