refactor: share cli runtime error handling
This commit is contained in:
@@ -4,6 +4,7 @@ import { docsSearchCommand } from "../commands/docs.js";
|
||||
import { defaultRuntime } from "../runtime.js";
|
||||
import { formatDocsLink } from "../terminal/links.js";
|
||||
import { theme } from "../terminal/theme.js";
|
||||
import { runCommandWithRuntime } from "./cli-utils.js";
|
||||
|
||||
export function registerDocsCli(program: Command) {
|
||||
program
|
||||
@@ -15,11 +16,8 @@ export function registerDocsCli(program: Command) {
|
||||
() => `\n${theme.muted("Docs:")} ${formatDocsLink("/cli/docs", "docs.clawd.bot/cli/docs")}\n`,
|
||||
)
|
||||
.action(async (queryParts: string[]) => {
|
||||
try {
|
||||
await runCommandWithRuntime(defaultRuntime, async () => {
|
||||
await docsSearchCommand(queryParts, defaultRuntime);
|
||||
} catch (err) {
|
||||
defaultRuntime.error(String(err));
|
||||
defaultRuntime.exit(1);
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user