UNPKG

openclaw

Version:

Multi-channel AI gateway with extensible messaging integrations

45 lines (44 loc) 1.26 kB
import "./errors-Db3Ymjlb.js"; import { a as isExpectedCliError, i as formatCliOperatorError } from "./failure-output-Dc5ce9_F.js"; import { r as isJsonOutputModeActive } from "./json-output-mode-D0F07HLf.js"; //#region src/cli/cli-utils.ts async function withManager(params) { const { manager, error } = await params.getManager(); if (!manager) { params.onMissing(error); return; } try { await params.run(manager); } finally { try { await params.close(manager); } catch (err) { params.onCloseError?.(err); } } } async function runCommandWithRuntime(runtime, action, onError) { try { await action(); } catch (err) { const { ExitError } = await import("./runtime-DixL8FcQ.js"); if (err instanceof ExitError || isJsonOutputModeActive(process.argv) || isExpectedCliError(err)) throw err; if (onError) { onError(err); return; } runtime.error(formatCliOperatorError(err)); runtime.exit(1); } } function resolveOptionFromCommand(command, key) { let current = command; while (current) { const opts = current.opts?.() ?? {}; if (opts[key] !== void 0) return opts[key]; current = current.parent ?? void 0; } } //#endregion export { runCommandWithRuntime as n, withManager as r, resolveOptionFromCommand as t };