openclaw
Version:
Multi-channel AI gateway with extensible messaging integrations
3 lines • 948 B
JavaScript
import{O as hasCommanderOptionToken,s as hasFlag}from"./argv-BgC5-KlV.mjs";
//!src/cli/program/json-mode.ts
const jsonModeSymbol=Symbol(`openclaw.cli.jsonMode`);const JSON_FLAG=/* @__PURE__ */ new Set([`--json`]);function commandDefinesJsonOption(e){return e.options.some(e=>e.long===`--json`)}function getCommandJsonMode(e,t=process.argv){const n=hasFlag(t,`--json`)&&!hasCommanderOptionToken(e,t,JSON_FLAG,`value`);const r=e.optsWithGlobals().json===true||n;for(let n=e;n;n=n.parent??null){const i=n[jsonModeSymbol];if(i?.resolve?.({command:e,argv:t,stdoutIsTTY:process.stdout.isTTY||false}))return i.mode;if(i&&!i.resolve&&r)return i.mode;if(r&&commandDefinesJsonOption(n))return`output`}return null}function setCommandJsonMode(e,t,n){e[jsonModeSymbol]={mode:t,...n?{resolve:n}:{}};return e}function isCommandJsonOutputMode(e,t=process.argv){return getCommandJsonMode(e,t)===`output`}export{setCommandJsonMode as n,isCommandJsonOutputMode as t};