unofficial mirror of guix-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Sahitihi <sahi@swecha.net>
To: "Gábor Boskovits" <boskovits@gmail.com>
Cc: guix-devel <guix-devel@gnu.org>
Subject: Re: Fwd: Re: Patch file for colorize module
Date: Mon, 11 Jun 2018 21:51:58 +0530	[thread overview]
Message-ID: <c1a084e9-b888-1d01-b1fe-3e423169e750@swecha.net> (raw)
In-Reply-To: <CAE4v=pjiR2fVN3SoA+NqSt4T9VEvM9Gfsz9OUPW=7X9RnNE7mg@mail.gmail.com>


[-- Attachment #1.1: Type: text/plain, Size: 98 bytes --]

Hi Gábor,

Updated patch is attached.

> Could you send an updated patch?

---
Thanks!!
Sahithi.

[-- Attachment #1.2: Type: text/html, Size: 515 bytes --]

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-guix-Add-coloring-soft-port.patch --]
[-- Type: text/x-patch; name="0001-guix-Add-coloring-soft-port.patch", Size: 3503 bytes --]

From 765035232a43f09a5c3dbecf77c90499dd1473d4 Mon Sep 17 00:00:00 2001
From: Sahithi Yarlagadda <sahi@swecha.net>
Date: Tue, 5 Jun 2018 00:08:32 +0530
Subject: [PATCH] guix: Add coloring soft port.

* guix/ui.scm (handle-string): New procedures.
(colorful-build-output-port): New variable.

guix: Added colorful-build-output-port to build.scm instead of default
---
 guix/scripts/build.scm |  5 +----
 guix/ui.scm            | 42 +++++++++++++++++++++++++++++++++++++++++-
 2 files changed, 42 insertions(+), 5 deletions(-)
 mode change 100644 => 100755 guix/scripts/build.scm
 mode change 100644 => 100755 guix/ui.scm

diff --git a/guix/scripts/build.scm b/guix/scripts/build.scm
old mode 100644
new mode 100755
index 4dd4fbccd..be457443b
--- a/guix/scripts/build.scm
+++ b/guix/scripts/build.scm
@@ -732,10 +732,7 @@ needed."
       (with-store store
         ;; Set the build options before we do anything else.
         (set-build-options-from-command-line store opts)
-
-        (parameterize ((current-build-output-port (if quiet?
-                                                      (%make-void-port "w")
-                                                      (current-error-port))))
+(parameterize ((current-build-output-port  colorful-build-output-port))
           (let* ((mode  (assoc-ref opts 'build-mode))
                  (drv   (options->derivations store opts))
                  (urls  (map (cut string-append <> "/log")
diff --git a/guix/ui.scm b/guix/ui.scm
old mode 100644
new mode 100755
index 80f1a4d77..83302ce30
--- a/guix/ui.scm
+++ b/guix/ui.scm
@@ -109,7 +109,7 @@
             warning
             info
             guix-main
-            colorize-string))
+            colorful-build-output-port))
 
 ;;; Commentary:
 ;;;
@@ -1631,4 +1631,44 @@ be reset such that subsequent output will not have any colors in effect."
    str
    (color 'RESET)))
 
+ 
+(define (handle-string str)
+    (let ((message  (or (and=> (string-match "^(starting phase)(.*)" str)
+           (lambda (m)
+             (string-append
+               (colorize-string (match:substring m 1) 'BLUE)
+               (colorize-string (match:substring m 2) 'GREEN))))
+
+       (and=> (string-match "^(phase) (.*) (succeeded after) (.*) (seconds)" str)
+          (lambda (m)
+            (string-append
+              (colorize-string (match:substring m 1) 'BLUE)
+              (colorize-string (match:substring m 2) 'GREEN)
+              (colorize-string (match:substring m 3) 'BLUE)
+              (colorize-string (match:substring m 4) 'GREEN)
+              (colorize-string (match:substring m 5) 'BLUE))))
+
+       (and=> (string-match "^(phase)(.*) (failed after) (.*) (seconds)" str)
+          (lambda (m)
+            (string-append
+              (colorize-string (match:substring m 1) 'RED)
+              (colorize-string (match:substring m 2) 'GREEN)
+              (colorize-string (match:substring m 3) 'RED)
+              (colorize-string (match:substring m 4) 'GREEN)
+              (colorize-string (match:substring m 5) 'RED))))
+
+    ;; Didn’t match, so return unmodified string.
+       str)))
+    (display message (current-error-port))))
+
+(define colorful-build-output-port
+  (make-soft-port
+   (vector
+    (lambda (c) (write c (current-error-port)))
+    handle-string
+    (lambda () (display "." (current-error-port)))
+    (lambda () (char-upcase (read-char)))
+    (lambda () (display "@" (current-error-port))))
+   "rw"))
+
 ;;; ui.scm ends here
-- 
2.11.0


  reply	other threads:[~2018-06-11 16:22 UTC|newest]

Thread overview: 68+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <8ea5d026-fab9-7b12-198e-610ad7743cb2@swecha.net>
     [not found] ` <871sfxev9w.fsf@elephly.net>
     [not found]   ` <7626275c-3eee-bb05-ab9d-4c88ec6f0329@swecha.net>
     [not found]     ` <87r2nvjte6.fsf@elephly.net>
     [not found]       ` <5ab51417-b635-9725-9f48-3bc3f9b61fdf@swecha.net>
     [not found]         ` <87tvsko2wd.fsf@elephly.net>
     [not found]           ` <7290013c-990d-3f7d-d8db-38e090ed766a@swecha.net>
     [not found]             ` <87zi28kt82.fsf@elephly.net>
     [not found]               ` <8573e97d-d107-cde6-cd17-35f4ef6d2de3@swecha.net>
     [not found]                 ` <87k1takumm.fsf@elephly.net>
     [not found]                   ` <87o9hycwl6.fsf@elephly.net>
2018-05-11 21:16                     ` Status of Submitted Patches Sahithi Yarlagadda
2018-05-11 22:21                       ` Ricardo Wurmus
2018-05-12  7:50                         ` Ricardo Wurmus
2018-05-15 17:41                         ` Sahitihi
2018-05-20  9:40                           ` Ricardo Wurmus
2018-05-20 10:47                             ` Gábor Boskovits
2018-05-20 13:46                               ` Ricardo Wurmus
2018-05-23  7:53                             ` Sahitihi
2018-05-23  8:21                               ` Ricardo Wurmus
2018-05-24 17:16                                 ` Sahitihi
2018-05-24 20:00                                   ` Ricardo Wurmus
2018-05-25  3:43                                 ` Sahitihi
2018-05-25  5:18                                   ` Ricardo Wurmus
2018-05-25 17:59                                     ` Patch file for colorize module Sahitihi
2018-05-26  6:06                                       ` Sahitihi
2018-05-26  9:35                                         ` Ricardo Wurmus
2018-05-26 12:06                                           ` Sahitihi
2018-05-26 14:16                                             ` Ricardo Wurmus
2018-05-26 18:22                                               ` Sahitihi
2018-05-26 18:38                                                 ` Sahitihi
2018-05-26 21:20                                                   ` Ricardo Wurmus
2018-05-27 15:49                                                     ` Gábor Boskovits
2018-05-31  6:26                                               ` Fwd: " Ricardo Wurmus
2018-05-31 18:25                                                 ` Sahitihi
2018-05-31 19:28                                                   ` Ricardo Wurmus
2018-06-02 15:01                                                     ` Ricardo Wurmus
2018-06-03 14:18                                                     ` Sahitihi
2018-06-03 19:30                                                       ` Ricardo Wurmus
2018-06-04  7:48                                                         ` Sahitihi
2018-06-04 10:03                                                           ` Ricardo Wurmus
2018-06-04 18:51                                                             ` Sahitihi
2018-06-05 19:44                                                               ` Ricardo Wurmus
2018-06-06 19:49                                                                 ` Sahitihi
2018-06-06 20:06                                                                   ` Ricardo Wurmus
2018-06-06 21:20                                                                     ` Sahitihi
2018-06-06 21:28                                                                       ` Ricardo Wurmus
2018-06-07  3:29                                                                         ` Sahitihi
2018-06-07  5:22                                                                           ` Ricardo Wurmus
2018-06-07  7:47                                                                             ` Sahitihi
2018-06-07  8:25                                                                               ` Ricardo Wurmus
2018-06-08 17:01                                                                                 ` Sahitihi
2018-06-09  0:57                                                                                   ` Ricardo Wurmus
2018-06-09 18:08                                                                                     ` Sahitihi
2018-06-09 20:57                                                                                       ` Ricardo Wurmus
2018-06-11 12:14                                                                                         ` Sahitihi
2018-06-11 12:28                                                                                           ` Gábor Boskovits
2018-06-11 16:21                                                                                             ` Sahitihi [this message]
2018-06-12 14:12                                                                                               ` Ricardo Wurmus
2018-06-12 21:06                                                                                                 ` Sahitihi
2018-06-12 22:12                                                                                                   ` Ricardo Wurmus
2018-06-13 16:08                                                                                                     ` Sahithi Yarlagadda
2018-06-13 19:15                                                                                                       ` Ricardo Wurmus
2018-06-15 20:16                                                                                                         ` Sahitihi
2018-06-15 21:47                                                                                                           ` Next steps Ricardo Wurmus
2018-06-16 14:55                                                                                                             ` Sahitihi
2018-06-21 11:05                                                                                                               ` Ricardo Wurmus
2018-06-21 16:54                                                                                                                 ` Sahithi Yarlagadda
2018-06-25 20:13                                                                                                                   ` Sahithi Yarlagadda
2018-06-25 20:28                                                                                                                     ` Ricardo Wurmus
2018-06-26 20:01                                                                                                                       ` Gábor Boskovits
2018-06-29 22:51                                                                                                                       ` Sahithi Yarlagadda
2018-07-03  2:29                                                                                                                         ` Sahithi Yarlagadda
2018-06-24 18:25                                                                                                             ` Sahithi Yarlagadda
2018-06-24 20:22                                                                                                               ` Ricardo Wurmus
2018-06-24 20:33                                                                                                                 ` Sahithi Yarlagadda
2018-06-11 12:37                                                                                           ` Fwd: Re: Patch file for colorize module Ricardo Wurmus
2018-06-11 16:31                                                                                             ` Sahitihi
2018-06-04 11:41                                                         ` Ludovic Courtès

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

  List information: https://guix.gnu.org/

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

  git send-email \
    --in-reply-to=c1a084e9-b888-1d01-b1fe-3e423169e750@swecha.net \
    --to=sahi@swecha.net \
    --cc=boskovits@gmail.com \
    --cc=guix-devel@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 public inbox

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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).