addArgument('key', InputArgument::REQUIRED, 'Plugin key (kebab-case format, e.g. test-demo)') ->addOption('target', 't', InputOption::VALUE_OPTIONAL, 'Target directory path', null); } /** * 执行命令 */ public function __invoke(InputInterface $input, OutputInterface $output): int { $io = new SymfonyStyle($input, $output); $io->title('Build Plugin'); // 获取参数 $pluginKey = $input->getArgument('key'); $targetDirectory = $input->getOption('target'); $io->info(sprintf("Building plugin: %s", $pluginKey)); if ($targetDirectory) { $io->info(sprintf("Target directory: %s", $targetDirectory)); } else { $io->info("Target directory: Default (runtime/plugins)"); } try { // 创建插件开发服务实例 $pluginDevelopService = new PluginDevelopService(); // 构建插件 $result = $pluginDevelopService->build($pluginKey, $targetDirectory); if ($result['code'] === 200) { $io->success("Plugin built successfully!"); $io->text(sprintf("ZIP file path: %s", $result['data']['zip_file_path'])); return parent::SUCCESS; } else { return $this->outputError($io, sprintf("Build failed: %s", $result['message'])); } } catch (\Exception $e) { return $this->outputError($io, sprintf("Build failed: %s", $e->getMessage()), $e); } } }