summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLudovic Courtès <ludo@gnu.org>2019-01-27 22:44:34 +0100
committerLudovic Courtès <ludo@gnu.org>2019-01-29 12:09:52 +0100
commit3854c6429c648df5b5ab23f871de9ec3c466f61b (patch)
tree5a70239acc22d124c471aff8f5e7234c882b0ead
parent73a8681a16869a2b3a9da1c7ba9434e07a204e19 (diff)
downloadpatches-3854c6429c648df5b5ab23f871de9ec3c466f61b.tar
patches-3854c6429c648df5b5ab23f871de9ec3c466f61b.tar.gz
status: Print a progress bar for on-going builds when possible.
* guix/status.scm (print-build-event)[report-build-progress]: New procedure. [print-log-line]: Add ID parameter. Call 'report-build-progress' when appropriate. Adjust callers.
-rw-r--r--guix/status.scm27
1 files changed, 21 insertions, 6 deletions
diff --git a/guix/status.scm b/guix/status.scm
index 0435d14d6a..e3375816c5 100644
--- a/guix/status.scm
+++ b/guix/status.scm
@@ -441,14 +441,29 @@ addition to build events."
(cut colorize-string <> 'RED 'BOLD)
identity))
+ (define (report-build-progress %)
+ (let ((% (min (max % 0) 100))) ;sanitize
+ (erase-current-line port)
+ (format port "~3d% " (inexact->exact (round %)))
+ (display (progress-bar % (- (current-terminal-columns) 5))
+ port)
+ (force-output port)))
+
(define print-log-line
(if print-log?
(if colorize?
- (lambda (line)
+ (lambda (id line)
(display (colorize-log-line line) port))
- (cut display <> port))
- (lambda (line)
- (spin! port))))
+ (lambda (id line)
+ (display line port)))
+ (lambda (id line)
+ (match (build-status-building status)
+ ((build) ;single job
+ (match (build-completion build)
+ ((? number? %) (report-build-progress %))
+ (_ (spin! port))))
+ (_
+ (spin! port))))))
(unless print-log?
(display "\r" port)) ;erase the spinner
@@ -552,7 +567,7 @@ addition to build events."
;; through.
(display line port)
(force-output port))
- (print-log-line line))
+ (print-log-line pid line))
(cond ((string-prefix? "substitute: " line)
;; The daemon prefixes early messages coming with 'guix
;; substitute' with "substitute:". These are useful ("updating
@@ -565,7 +580,7 @@ addition to build events."
(display (info (string-trim-right line)) port)
(newline))
(else
- (print-log-line line)))))
+ (print-log-line pid line)))))
(_
event)))