Expand description
When the driver’s human output is coloured, and the few styles it uses.
One decision for the whole process, set once from the global --color
(alias --colour) flag: auto (the default), always or never. Under
auto a stream is coloured when it is a terminal, or when FORCE_COLOR or
CLICOLOR_FORCE asks for colour without one, and never when NO_COLOR is
set (allowed has the exact rules). always and never override the
terminal check and the environment alike.
The palette has one meaning per colour: blue for information, green for success, red for an error or a failure, amber for a warning, and bold for a heading.
Machine-readable output (--format json, ndjson, and bynk check’s and
bynk doctor’s short) is never coloured, whatever the choice: only the
human renderings ask this module.
Structs§
- Test
Lines bynk test’s human output (the runner’s, as it is forwarded), coloured a line at a time: a passing case’s✓green, a failing case red, a suite heading bold, a detached effect’s report yellow, and the closing tally’s counts green and, when any failed, red. Any other line passes through as it is. A heading is a line the runner starts after a blank one (each suite’s results end with one, andRunning tests...with two), so a test’s ownconsole.log("Response:")mid-suite is not taken for one.
Enums§
- Colour
Choice --color <WHEN>: when to colour the driver’s human output.- Style
- A style the driver paints text in: one meaning per colour.
Functions§
- apply_
to_ child - Make a child process (a
wrangler) whose output reaches the user colour as we do: undernever,NO_COLORset andFORCE_COLORtaken away; underalways, the reverse. Underautothe child decides for itself, unless its output ispipedthrough us, where it can no longer see our terminal: thenFORCE_COLORwhen we would colour stderr. - choice
- This process’s choice.
- coverage_
style - The style for a coverage percentage: green from 80%, yellow (amber) from 50%, red below.
- eprint
eprint!("{text}"), coloured asstderr_messagehas it.- eprint_
message - Print
textand a newline to stderr, asstderr_messagehas it. Whatemsg!expands to. - eprintln
eprintln!("{text}"), coloured asstderr_messagehas it.- message
- A message for stderr (
bynk: warning: …), with itserror:,warning:ornote:label red, amber or blue: the first such label on each line, whether it opens the line (after any indent or=) or follows thebynk …:or<program> …:that names who is speaking. Nothing else changes, so a line with no label is returned as it is. - paint
textinstylewhenon, otherwisetextunchanged.- set_
choice - Set this process’s choice (from
--color). Until it is called the choice isColourChoice::Auto. - stderr
- Whether human output on stderr is coloured.
- stderr_
message textfor stderr: its labels coloured asmessagedoes when stderr is coloured, and unchanged when it isn’t.- stdout
- Whether human output on stdout is coloured.