This commit is contained in:
2025-04-25 02:14:24 +08:00
parent 6827945446
commit 9eb4d06939
38 changed files with 1941 additions and 42 deletions

View File

@@ -0,0 +1,24 @@
import { program, Command } from '@/program.ts';
import { AssistantInit } from '@/services/init/index.ts';
import path from 'node:path';
type InitCommandOptions = {
path?: string;
};
const Init = new Command('init')
.description('初始化一个助手客户端,生成配置文件。')
.option('-p --path <path>', '助手路径,默认为执行命令的目录,如果助手路径不存在则创建。')
.action((opts: InitCommandOptions) => {
// 如果path参数存在检测path是否是相对路径如果是相对路径则转换为绝对路径
if (opts.path && !opts.path.startsWith('/')) {
opts.path = path.join(process.cwd(), opts.path);
} else if (opts.path) {
opts.path = path.resolve(opts.path);
}
const assistantInit = new AssistantInit({
path: opts.path,
});
assistantInit.init();
});
program.addCommand(Init);