openclaw
Version:
Multi-channel AI gateway with extensible messaging integrations
35 lines (34 loc) • 1.04 kB
JavaScript
//#region src/cli/command-options.ts
function hasExplicitOptions(e, t) {
return t.some((t) => e.getOptionValueSource(t) === "cli");
}
function listExplicitOptionFlagsExcept(e, t) {
const n = /* @__PURE__ */ new Map();
for (const r of e.options) {
const i = r.attributeName();
if (t.has(i) || e.getOptionValueSource(i) !== "cli") continue;
const a = n.get(i);
const o = e.getOptionValue(i) === false;
if (!a || r.negate === o) n.set(i, r);
}
return [...n.values()].map((e) => e.long ?? e.short ?? e.flags).toSorted();
}
const MAX_INHERIT_DEPTH = 2;
function inheritOptionFromParent(e, t, n) {
if (!e) return;
const r = e.getOptionValueSource(t);
if (r && r !== "default") return;
let i = 0;
let a = e.parent;
while (a && i < MAX_INHERIT_DEPTH) {
const e = a.getOptionValueSource(t);
if (e && e !== "default") {
if (n && e !== n) return;
return a.getOptionValue(t);
}
i += 1;
a = a.parent;
}
}
//#endregion
export { inheritOptionFromParent as n, listExplicitOptionFlagsExcept as r, hasExplicitOptions as t };