From mboxrd@z Thu Jan 1 00:00:00 1970 From: Danny Milosavljevic Subject: Re: User-Friendlyness of Guix and non-scaryness, printing messages Date: Sun, 28 May 2017 22:58:23 +0200 Message-ID: <20170528225823.6db84e61@scratchpost.org> References: <87bbe3e5.AEAAKL2r-KIAAAAAAAAAAAOtUOAAAAACwQwAAAAAAAW9WABZGcQo@mailjet.com> <87y3tw4kw3.fsf@gnu.org> <87r2zfx0xt.fsf@gnu.org> <427678e8.AEUAKjfDcSgAAAAAAAAAAAPB0agAAAACwQwAAAAAAAW9WABZKceD@mailjet.com> <20170528204437.6dfd35c4@scratchpost.org> <20170528210146.530b3f17@scratchpost.org> <20170528223517.612a87df@scratchpost.org> Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:59113) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dF5Gl-0005CE-72 for guix-devel@gnu.org; Sun, 28 May 2017 16:58:36 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dF5Gg-0005Bn-Bj for guix-devel@gnu.org; Sun, 28 May 2017 16:58:35 -0400 Received: from dd1012.kasserver.com ([85.13.128.8]:47708) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dF5Gg-0005Bb-5S for guix-devel@gnu.org; Sun, 28 May 2017 16:58:30 -0400 Received: from localhost (77.118.168.222.wireless.dyn.drei.com [77.118.168.222]) by dd1012.kasserver.com (Postfix) with ESMTPSA id 3A7CE1CA0710 for ; Sun, 28 May 2017 22:58:28 +0200 (CEST) In-Reply-To: <20170528223517.612a87df@scratchpost.org> 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: guix-devel@gnu.org And also the spinner integrated: diff --git a/guix/scripts/package.scm b/guix/scripts/package.scm index f050fad97..d9ac61122 100644 --- a/guix/scripts/package.scm +++ b/guix/scripts/package.scm @@ -46,6 +46,7 @@ #:use-module (srfi srfi-34) #:use-module (srfi srfi-35) #:use-module (srfi srfi-37) + #:use-module (rnrs io ports) #:use-module (gnu packages) #:autoload (gnu packages base) (canonical-package) #:autoload (gnu packages guile) (guile-2.0) @@ -187,6 +188,27 @@ denote ranges as interpreted by 'matching-generations'." (else (leave (G_ "invalid syntax: ~a~%") pattern))))) +(define previous-output-port (current-error-port)) + +(define spinner-port + (let ((index 0) + (spinner-chars "|\\-/")) + (define (spin) + (set! index (+ index 1)) + (if (>= index (string-length spinner-chars)) + (set! index 0)) + (display (array-ref spinner-chars index) previous-output-port) + (display #\backspace previous-output-port) + (flush-output-port previous-output-port)) + (make-soft-port + (vector + (lambda (c) (if (char=? c #\newline) (spin))) ; putc + (lambda (s) (if (string-contains s "\n") (spin))) ; puts + (lambda () #t) ; flush + (lambda () #f) ; getc + (lambda () #t)) ; close + "w"))) + (define* (build-and-use-profile store profile manifest #:key bootstrap? use-substitutes? @@ -196,6 +218,7 @@ specified in MANIFEST, a manifest object." (when (equal? profile %current-profile) (ensure-default-profile)) + (parameterize ((current-build-output-port spinner-port)) (let* ((prof-drv (run-with-store store (profile-derivation manifest #:hooks (if bootstrap? @@ -230,7 +253,7 @@ specified in MANIFEST, a manifest object." count) count) (display-search-paths entries (list profile) - #:kind 'prefix)))))))) + #:kind 'prefix))))))))) ^L ;;;