ansiStatus function

String ansiStatus(
  1. String token, {
  2. required bool color,
})

Colours a doctor status token: green = good, red = bad, yellow = anything else (unknown / n/a). Returns token unchanged when color is false, so callers stay plain in tests and pipes.

Implementation

String ansiStatus(String token, {required bool color}) {
  if (!color) return token;
  if (_goodTokens.contains(token)) return _c(_green, token, color: color);
  if (_badTokens.contains(token)) return _c(_red, token, color: color);
  return _c(_yellow, token, color: color);
}