addArgument('name', InputArgument::REQUIRED, 'Plugin name') ->addArgument('mode', InputArgument::OPTIONAL, 'Install mode (local/market)', 'local'); } /** * 执行命令 */ public function __invoke(InputInterface $input, OutputInterface $output): int { $io = new SymfonyStyle($input, $output); $io->title('Plugin Installer'); // 获取参数 $name = $input->getArgument('name'); $mode = $input->getArgument('mode'); $io->info("Installing plugin: {$name}"); $io->info("Install mode: {$mode}"); try { // 创建安装服务实例 $installService = new PluginInstallService(); // 执行安装流程(使用基类的流式处理) return $this->executeStream($installService->install($name, $mode), $io, $name); } catch (\Exception $e) { return $this->outputError($io, sprintf("Installation failed: %s", $e->getMessage()), $e); } } }