temp
This commit is contained in:
24
assistant/src/command/init/index.ts
Normal file
24
assistant/src/command/init/index.ts
Normal 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);
|
||||
Reference in New Issue
Block a user