import * as Context from "../Context.ts"; import * as Layer from "../Layer.ts"; import * as Stdio from "../Stdio.ts"; /** * Terminal rendering flags for the current process. * * **Details** * * `canColor` says whether styling will be rendered rather than stored as * bytes. `canAnimate` says whether output is being watched, so pacing means * something. `canPrompt` says whether a question can be asked and answered. * Only `canColor` is read by the built-in `Command` output; the other two are * for application code that renders its own output. * * @stability unstable * @category models * @since 4.0.0 */ export interface TerminalCapabilities { readonly canColor: boolean; readonly canAnimate: boolean; readonly canPrompt: boolean; } /** * Reference to the terminal capabilities of the current process. * * **When to use** * * Use when application output should share the built-in help, version, and * error output's answer. Provide `layer` to detect through * `ConfigProvider` and `Stdio`, or provide a value to override detection. * * **Details** * * The default is detected from the current process the first time it is * read, so later changes to the environment do not affect it. Without a * `process` global, every flag is `false`. * * @stability unstable * @category services * @since 4.0.0 */ export declare const TerminalCapabilities: Context.Reference; /** * Detects terminal capabilities from `Stdio` and the current `ConfigProvider`. * * **Details** * * `TERM=dumb` clears all three flags, because a terminal that cannot move the * cursor can neither animate nor redraw a prompt. Otherwise `NO_COLOR`, when * set to any non-empty value, disables color and wins over `FORCE_COLOR`. * `FORCE_COLOR` forces color even off a TTY, except for `0` and `false`, which * mean "not forcing". Empty variables count as unset, matching * `ConfigProvider.fromEnv`, so `FORCE_COLOR=` does not force color on. * `canPrompt` requires both standard input and standard output to be * terminals. A `ConfigProvider` fault is a defect, so the layer never fails. * * **Example** (NO_COLOR wins over FORCE_COLOR) * * ```ts import.meta.vitest * import { ConfigProvider, Effect, Stdio } from "effect" * import { TerminalCapabilities } from "effect/cli" * * const program = Effect.gen(function*() { * const caps = yield* TerminalCapabilities.TerminalCapabilities * return caps.canColor * }).pipe( * Effect.provide(TerminalCapabilities.layer), * Effect.provide(Stdio.layerTest({ stdoutIsTerminal: Effect.succeed(true) })), * Effect.provideService( * ConfigProvider.ConfigProvider, * ConfigProvider.fromEnv({ env: { NO_COLOR: "1", FORCE_COLOR: "1" } }) * ) * ) * * Effect.runSync(program) // => false * ``` * * @stability unstable * @category layers * @since 4.0.0 */ export declare const layer: Layer.Layer; //# sourceMappingURL=TerminalCapabilities.d.ts.map