addArgument('handle', InputArgument::REQUIRED, 'Module handle to uninstall') ->addOption('force', 'f', InputOption::VALUE_NONE, 'Skip confirmation prompt') ->setHelp('This command uninstalls an installed module.') ; } protected function execute(InputInterface $input, OutputInterface $output): int { $io = new SymfonyStyle($input, $output); $handle = $input->getArgument('handle'); $force = $input->getOption('force'); $io->title('Uninstall Module'); try { // Prevent uninstalling core module if ($handle === 'core') { $io->error('Cannot uninstall the core module.'); return Command::FAILURE; } // Find the module $module = $this->moduleManager->fetch($handle); if (!$module) { $io->error("Module '{$handle}' not found or not installed."); return Command::FAILURE; } // Confirm unless --force is passed if (!$force && !$io->confirm("Are you sure you want to uninstall module '{$handle}'?", false)) { $io->text('Uninstall cancelled.'); return Command::SUCCESS; } // Uninstall the module $io->text("Uninstalling module '{$handle}'..."); $this->moduleManager->uninstall($handle); $this->logger->info('Module uninstalled via console', [ 'handle' => $handle, 'command' => $this->getName(), ]); $io->success("Module '{$handle}' uninstalled successfully!"); return Command::SUCCESS; } catch (\Throwable $e) { $io->error('Failed to uninstall module: ' . $e->getMessage()); $this->logger->error('Module uninstall failed', [ 'handle' => $handle, 'error' => $e->getMessage(), ]); return Command::FAILURE; } } }