Quellcodebibliothek Statistik Leitseite products/Sources/formale Sprachen/Java/Openclaw/src/cli/program/   (KI Agentensystem Version 22©)  Datei vom 26.3.2026 mit Größe 1 kB image not shown  

Quelle  json-mode.ts

  Sprache: JAVA
 

Spracherkennung für: .ts vermutete Sprache: Unknown {[0] [0] [0]} [Methode: Schwerpunktbildung, einfache Gewichte, sechs Dimensionen]

import type { Command } from "commander";
import { hasFlag } from "../argv.js";

const jsonModeSymbol = Symbol("openclaw.cli.jsonMode");

type JsonMode = "output" | "parse-only";
type JsonModeCommand = Command & {
  [jsonModeSymbol]?: JsonMode;
};

function commandDefinesJsonOption(command: Command): boolean {
  return command.options.some((option) => option.long === "--json");
}

function getDeclaredCommandJsonMode(command: Command): JsonMode | null {
  for (let current: Command | null = command; current; current = current.parent ?? null) {
    const metadata = (current as JsonModeCommand)[jsonModeSymbol];
    if (metadata) {
      return metadata;
    }
    if (commandDefinesJsonOption(current)) {
      return "output";
    }
  }
  return null;
}

function commandSelectedJsonFlag(command: Command, argv: string[]): boolean {
  const commandWithGlobals = command as Command & {
    optsWithGlobals?: () => Record<string, unknown>;
  };
  if (typeof commandWithGlobals.optsWithGlobals === "function") {
    const resolved = commandWithGlobals.optsWithGlobals().json;
    if (resolved === true) {
      return true;
    }
  }
  return hasFlag(argv, "--json");
}

export function setCommandJsonMode(command: Command, mode: JsonMode): Command {
  (command as JsonModeCommand)[jsonModeSymbol] = mode;
  return command;
}

export function getCommandJsonMode(
  command: Command,
  argv: string[] = process.argv,
): JsonMode | null {
  if (!commandSelectedJsonFlag(command, argv)) {
    return null;
  }
  return getDeclaredCommandJsonMode(command);
}

export function isCommandJsonOutputMode(command: Command, argv: string[] = process.argv): boolean {
  return getCommandJsonMode(command, argv) === "output";
}

¤ Dauer der Verarbeitung: 0.1 Sekunden  (vorverarbeitet am  2026-04-27) ¤

*© Formatika GbR, Deutschland






Wurzel

Suchen

Beweissystem der NASA

Beweissystem Isabelle

NIST Cobol Testsuite

Cephes Mathematical Library

Wiener Entwicklungsmethode

Haftungshinweis

Die Informationen auf dieser Webseite wurden nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit, noch Qualität der bereit gestellten Informationen zugesichert.

Bemerkung:

Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.