aboutsummaryrefslogtreecommitdiff
path: root/src/libutil/terminal.hh
diff options
context:
space:
mode:
authorJade Lovelace <lix@jade.fyi>2024-08-01 12:26:16 -0700
committerJade Lovelace <lix@jade.fyi>2024-08-04 20:41:19 -0700
commit378ec5fb0611e314511a7afc806664205846fc2e (patch)
treedab3a3cb9e7f91dc77956fb99cf4cac711c760d0 /src/libutil/terminal.hh
parent700762d8b24350bbe537258167244ec9c84fcae3 (diff)
Implement forcing CLI colour on, and document it better
This is necessary to make some old tests work when testing colour against non-interactive outputs. Change-Id: Id89f8a1f45c587fede35a69db85f7a52f2c0a981
Diffstat (limited to 'src/libutil/terminal.hh')
-rw-r--r--src/libutil/terminal.hh9
1 files changed, 9 insertions, 0 deletions
diff --git a/src/libutil/terminal.hh b/src/libutil/terminal.hh
index 43df5bd70..6b8d59182 100644
--- a/src/libutil/terminal.hh
+++ b/src/libutil/terminal.hh
@@ -9,6 +9,15 @@ namespace nix {
/**
* Determine whether ANSI escape sequences are appropriate for the
* present output.
+ *
+ * This follows the rules described on https://bixense.com/clicolors/
+ * with CLICOLOR defaulted to enabled (and thus ignored).
+ *
+ * That is to say, the following procedure is followed in order:
+ * - NO_COLOR or NOCOLOR set -> always disable colour
+ * - CLICOLOR_FORCE or FORCE_COLOR set -> enable colour
+ * - The output is a tty; TERM != "dumb" -> enable colour
+ * - Otherwise -> disable colour
*/
bool shouldANSI();