Hi Danny, Danny Milosavljevic <dan...@scratchpost.org> 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’.