feat: 新增 rune update 命令用于更新编辑器配置
This commit is contained in:
29
src/cli.ts
29
src/cli.ts
@@ -129,6 +129,35 @@ cli.command("init [...tools]", "初始化 Rune 并注入工具配置").action(
|
||||
},
|
||||
);
|
||||
|
||||
cli.command("update [...tools]", "更新已注入的工具配置").action(
|
||||
async (tools: string[]) => {
|
||||
if (!tools || tools.length === 0) {
|
||||
throw new UsageError("请指定至少一个工具", {
|
||||
usage: "rune update <工具...>",
|
||||
hint: "如:rune update opencode",
|
||||
});
|
||||
}
|
||||
const root = requireProjectRoot();
|
||||
const { updateOpenCode } = await import("./adapters/opencode.ts");
|
||||
const { updateClaudeCode } = await import("./adapters/claude-code.ts");
|
||||
const validators: Record<string, (root: string) => Promise<void>> = {
|
||||
opencode: updateOpenCode,
|
||||
"claude-code": updateClaudeCode,
|
||||
};
|
||||
for (const tool of tools) {
|
||||
if (!validators[tool]) {
|
||||
throw new CommandError(`不支持的工具: ${tool}`, {
|
||||
hint: `支持的工具: ${Object.keys(validators).join(", ")}`,
|
||||
});
|
||||
}
|
||||
}
|
||||
for (const tool of tools) {
|
||||
await validators[tool](root);
|
||||
}
|
||||
console.log(`工具配置已更新:${tools.join(", ")}`);
|
||||
},
|
||||
);
|
||||
|
||||
cli.command("discuss", "讨论阶段").action(async () => {
|
||||
const root = requireProjectRoot();
|
||||
const config = await loadConfig(root);
|
||||
|
||||
Reference in New Issue
Block a user