feat: 助手配置与服务命令扩展及依赖更新
This commit is contained in:
31
assistant/src/command/asst-server/index.ts
Normal file
31
assistant/src/command/asst-server/index.ts
Normal file
@@ -0,0 +1,31 @@
|
||||
import { program, Command } from '@/program.ts';
|
||||
import { spawnSync } from 'node:child_process';
|
||||
|
||||
const command = new Command('server')
|
||||
.description('启动服务')
|
||||
.option('-d, --daemon', '是否以守护进程方式运行')
|
||||
.option('-n, --name <name>', '服务名称')
|
||||
.option('-p, --port <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);
|
||||
Reference in New Issue
Block a user