import { program, Command } from '@/program.ts'; import { spawnSync } from 'node:child_process'; const command = new Command('server') .description('启动服务') .option('-d, --daemon', '是否以守护进程方式运行') .option('-n, --name ', '服务名称') .option('-p, --port ', '服务端口') .option('-s, --start', '是否启动服务') .action((options) => { const { port } = options; const shellCommands = []; if (options.daemon) { shellCommands.push('-d'); } if (options.name) { shellCommands.push(`-n ${options.name}`); } if (options.start) { shellCommands.push('-s'); } if (port) { shellCommands.push(`-p ${port}`); } console.log(`Assistant server shell command: asst-server ${shellCommands.join(' ')}`); const child = spawnSync('asst-server', shellCommands, { stdio: 'inherit', shell: true, }); }); program.addCommand(command);