all messages for Guix-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Phil <phil@beadling.co.uk>
To: 54029@debbugs.gnu.org
Subject: [bug#54029] [PATCH] allow user to force color when not a tty
Date: Wed, 16 Feb 2022 18:28:03 +0000	[thread overview]
Message-ID: <87wnhuekek.fsf@beadling.co.uk> (raw)

[-- Attachment #1: Type: text/plain, Size: 737 bytes --]

Hi,

At the moment there doesn't seem to be any way to request ANSI stdout/err
from Guix if your output is not a tty.  However when capturing Guix
output for display inside a front-end for running jobs across many
servers (eg Jenkins, Rundeck, etc) - these tools are often capable of
rendering ANSI output captured from console tools like Guix.  Other
tools (eg py-test, flake8) often allow the user to explicitly force
color output even when a tty is not detected.  The attached patch is a
trivial attempt at make such an option available in Guix too.

I've done this in the least disruptive way possible, which is to
introduce an new env var such that users of the NO_COLOR env var will
get continuity of functionality.

Cheers,
Phil


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-allow-user-to-force-color-when-not-a-tty.patch --]
[-- Type: text/x-patch, Size: 871 bytes --]

From 010be2b6d4b1ec865a686345116deb92570636e2 Mon Sep 17 00:00:00 2001
From: "Phil.Beadling" <phil@beadling.co.uk>
Date: Wed, 16 Feb 2022 17:40:32 +0000
Subject: [PATCH] allow user to force color when not a tty

---
 guix/colors.scm | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/guix/colors.scm b/guix/colors.scm
index 3031f54799..c57c139864 100644
--- a/guix/colors.scm
+++ b/guix/colors.scm
@@ -131,8 +131,9 @@ that subsequent output will not have any colors in effect."
 
 (define (color-output? port)
   "Return true if we should write colored output to PORT."
-  (and (not (getenv "NO_COLOR"))
-       (isatty?* port)))
+  (or (getenv "GUIX_COLOR_OUTPUT")
+      (and (not (getenv "NO_COLOR"))
+           (isatty?* port))))
 
 (define (coloring-procedure color)
   "Return a procedure that applies COLOR to the given string."
-- 
2.25.1


                 reply	other threads:[~2022-02-16 20:14 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87wnhuekek.fsf@beadling.co.uk \
    --to=phil@beadling.co.uk \
    --cc=54029@debbugs.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/guix.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.