From mboxrd@z Thu Jan 1 00:00:00 1970 From: Sahitihi Subject: Re: Fwd: Re: Patch file for colorize module Date: Mon, 11 Jun 2018 21:51:58 +0530 Message-ID: References: <8ea5d026-fab9-7b12-198e-610ad7743cb2@swecha.net> <2f71be8d-c672-c66a-0b16-bc3abc748754@swecha.net> <877enjpquf.fsf@elephly.net> <557b30de-5aa2-113f-7e90-a4a23e86bb07@swecha.net> <87602zbrcc.fsf@elephly.net> <328742c6-f96f-74b8-68ef-3b165a6199aa@swecha.net> <87zi0a3m3t.fsf@elephly.net> <07c93c07-2172-6bf1-6188-88830c1d8b4c@swecha.net> <87o9gpyq4t.fsf@elephly.net> <91773c8b-3072-2a82-dca3-cbeb5adf826d@swecha.net> <87fu1zznl3.fsf@elephly.net> <87bmcnzjsp.fsf@elephly.net> <18408eca-ad0b-111a-0ef6-ab452c9ca89c@swecha.net> <878t7ryxvf.fsf@elephly.net> <02e1a59a-ebc1-dfce-e1d6-22e97e742214@swecha.net> <874lifypeb.fsf@elephly.net> <648f81fc-0607-2c3b-f9a3-ca3b29cd637b@swecha.net> <87bmck22uz.fsf@elephly.net> <8736xv1xvq.fsf@elephly.net> <64dfaf0c-3bcf-7b76-5831-b1c41d3f5563@swecha.net> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="------------8B73AEEF6D2F6D0E3E1E38CA" Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:37898) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fSPa4-0002sU-To for guix-devel@gnu.org; Mon, 11 Jun 2018 12:22:09 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fSPa0-0006Cz-Sg for guix-devel@gnu.org; Mon, 11 Jun 2018 12:22:08 -0400 In-Reply-To: Content-Language: en-US List-Id: "Development of GNU Guix and the GNU System distribution." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-devel-bounces+gcggd-guix-devel=m.gmane.org@gnu.org Sender: "Guix-devel" To: =?UTF-8?Q?G=c3=a1bor_Boskovits?= Cc: guix-devel This is a multi-part message in MIME format. --------------8B73AEEF6D2F6D0E3E1E38CA Content-Type: multipart/alternative; boundary="------------1AFA68142E6DC64F46DC45A8" --------------1AFA68142E6DC64F46DC45A8 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Hi Gábor, Updated patch is attached. > Could you send an updated patch? --- Thanks!! Sahithi. --------------1AFA68142E6DC64F46DC45A8 Content-Type: text/html; charset=utf-8 Content-Transfer-Encoding: 8bit

Hi Gábor,

Updated patch is attached.

Could you send an updated patch?

---
Thanks!!
Sahithi.
--------------1AFA68142E6DC64F46DC45A8-- --------------8B73AEEF6D2F6D0E3E1E38CA Content-Type: text/x-patch; name="0001-guix-Add-coloring-soft-port.patch" Content-Transfer-Encoding: 8bit Content-Disposition: attachment; filename="0001-guix-Add-coloring-soft-port.patch" >From 765035232a43f09a5c3dbecf77c90499dd1473d4 Mon Sep 17 00:00:00 2001 From: Sahithi Yarlagadda 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 --------------8B73AEEF6D2F6D0E3E1E38CA--