Skip to content

armgit / kaneo

Public Imported from GitHub
0

⚡ Project management that doesn't become the project. Boards, Gantt charts, and GitHub integration. Self-host it or use Kaneo Cloud.

628 B
Raw Blame
import type { Environment } from "../render/capabilities.js";

export type OutputMode = "json" | "human";

export function resolveOutputMode(
  argv: ReadonlyArray<string>,
  env: Environment,
  stdoutIsTTY: boolean,
): OutputMode {
  const end = argv.indexOf("--");
  const flags = end === -1 ? argv : argv.slice(0, end);
  if (flags.includes("--json")) return "json";
  if (flags.some((flag) => flag === "--jq" || flag.startsWith("--jq=")))
    return "json";
  if (flags.includes("--human")) return "human";
  if (env.KANEO_JSON === "true" || env.KANEO_JSON === "1") return "json";
  return stdoutIsTTY ? "human" : "json";
}