Looktypetype Look = palette.Capabilities & { readonly tty: boolean };What the terminal written to can show, and whether it is one.
How the command line looks (commons headless 0004-headless-cli FR-001, FR-002, FR-005): the marks, the colours and the widths. The marks are the terminal's one palette and no other (an ASCII fallback where the terminal shows no emoji); colour is written only where the look allows it; a text is cut to the columns of the terminal, never inside a character or an escape sequence. The spinner and the progress bar are pure functions of a number, so that a test draws them without a terminal.
import { line, progressBar } from "./style.ts";
const look = { tty: false, colour: false, emoji: false, columns: 80 };
line("ok", "built", look); // "[ok] built"
progressBar(5, 10, 10, look); // "[#####-----]"Looktypetype Look = palette.Capabilities & { readonly tty: boolean };What the terminal written to can show, and whether it is one.
Tonetypetype Tone = ProblemLevel | "ok" | "skip" | "hint" | "cancelled";What a line of output is about: a problem's level, or how something ended.
markKindOffunctionfunction markKindOf(tone: Tone): MarkKindThe mark of the palette a tone is written with (the palette's marks are the only marks).
markfunctionfunction mark(tone: Tone, look: Look): stringThe tone's mark, painted.
linefunctionfunction line(tone: Tone, text: string, look: Look): stringA line's beginning: the tone's mark, a space and the text.
paintfunctionno test imports itfunction paint(role: Role, text: string, look: Look): stringA text painted in a role.
dimfunctionno test imports itfunction dim(text: string, look: Look): stringA text dimmed.
SPINNERconstconst SPINNER: { readonly emoji: readonly string[]; readonly ascii: readonly string[]; }The frames of the spinner: braille where the terminal is a modern one (it shows emoji), else ASCII.
spinnerFramefunctionfunction spinnerFrame(step: number, look: Look): stringThe frame of the spinner at a step; any integer is a step.
progressBarfunctionfunction progressBar(n: number, total: number, width: number, look: Look): stringA progress bar of width cells for n of total: [█████░░░░░], or [#####-----] where the terminal shows no emoji.
fmtDurationfunctionfunction fmtDuration(ms: number): stringA duration for a person: 640ms, 12s, 1m12s, 2h03m.
fitfunctionfunction fit(text: string, look: Look): stringA line cut to the terminal's width (one column is left free so that the line never wraps), with … where it was cut.