guix-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: User-Friendlyness of Guix and non-scaryness, printing messages


From: Ludovic Courtès
Subject: Re: User-Friendlyness of Guix and non-scaryness, printing messages
Date: Tue, 30 May 2017 17:11:36 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/25.2 (gnu/linux)

Hi Danny,

Danny Milosavljevic <address@hidden> skribis:

> 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")))

Nice hack!  I don’t think we should incorporate it just right now; I
would prefer something that writes “building foo” or “downloading bar”
in addition to the spinner, like ‘wip-ui’ tries to do.

WDYT?

Ludo’.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]