addArgument('name', InputArgument::REQUIRED, 'Plugin name'); } /** * 执行命令 */ public function __invoke(InputInterface $input, OutputInterface $output): int { $io = new SymfonyStyle($input, $output); $io->title('Plugin Deleter'); // 获取参数 $name = $input->getArgument('name'); $io->info("Deleting plugin: {$name}"); $io->note("Note: Plugin must be uninstalled before deletion"); // 确认删除 if (!$this->confirm($io, "Are you sure you want to delete plugin {$name}? This action cannot be undone.")) { $io->note("Deletion cancelled"); return Command::SUCCESS; } try { // 创建删除服务实例(统一入口) $deleteService = new PluginUninstallService(); // 执行删除流程 $result = $deleteService->delete($name); if ($result) { return $this->outputSuccess($io, "Plugin '{$name}' deleted successfully!"); } else { return $this->outputError($io, "Plugin '{$name}' deletion failed!"); } } catch (\Exception $e) { return $this->outputError($io, sprintf("Deletion failed: %s", $e->getMessage()), $e); } } }