summaryrefslogtreecommitdiff
path: root/guix/scripts
diff options
context:
space:
mode:
authorLudovic Courtès <ludo@gnu.org>2022-06-19 22:53:52 +0200
committerLudovic Courtès <ludo@gnu.org>2022-06-19 23:14:56 +0200
commitab174e16b5832b1ff978740e6b4c48cf194c0a96 (patch)
treed71ba186a2849930df915f9623c5ada7647a2845 /guix/scripts
parent6337f62dde24ceaf50c25a0133346bba68c2d849 (diff)
challenge: Colorize output.
* guix/scripts/challenge.scm (good-news, bad-news): New procedures. (summarize-report, summarize-report-list): Use them and 'highlight'.
Diffstat (limited to 'guix/scripts')
-rw-r--r--guix/scripts/challenge.scm17
1 files changed, 12 insertions, 5 deletions
diff --git a/guix/scripts/challenge.scm b/guix/scripts/challenge.scm
index 96ffe53a85..5c0f837d13 100644
--- a/guix/scripts/challenge.scm
+++ b/guix/scripts/challenge.scm
@@ -18,6 +18,7 @@
(define-module (guix scripts challenge)
#:use-module (guix ui)
+ #:use-module (guix colors)
#:use-module (guix scripts)
#:use-module (guix store)
#:use-module (guix utils)
@@ -388,6 +389,11 @@ COMPARISON-REPORT."
(append command
(list directory1 directory2))))))
+(define good-news
+ (coloring-procedure (color BOLD GREEN)))
+(define bad-news
+ (coloring-procedure (color BOLD RED)))
+
(define* (summarize-report comparison-report
#:key
(report-differences (const #f))
@@ -410,7 +416,7 @@ with COMPARISON-REPORT."
(match comparison-report
(($ <comparison-report> item 'mismatch local (narinfos ...))
- (report (G_ "~a contents differ:~%") item)
+ (report (bad-news (G_ "~a contents differ:~%")) item)
(report-hashes item local narinfos)
(report-differences comparison-report))
(($ <comparison-report> item 'inconclusive #f narinfos)
@@ -419,7 +425,7 @@ with COMPARISON-REPORT."
(warning (G_ "could not challenge '~a': no substitutes~%") item))
(($ <comparison-report> item 'match local (narinfos ...))
(when verbose?
- (report (G_ "~a contents match:~%") item)
+ (report (good-news (G_ "~a contents match:~%")) item)
(report-hashes item local narinfos)))))
(define (summarize-report-list reports)
@@ -428,10 +434,11 @@ with COMPARISON-REPORT."
(inconclusive (count comparison-report-inconclusive? reports))
(matches (count comparison-report-match? reports))
(discrepancies (count comparison-report-mismatch? reports)))
- (report (G_ "~h store items were analyzed:~%") total)
- (report (G_ " - ~h (~,1f%) were identical~%")
+ (report (highlight (G_ "~h store items were analyzed:~%")) total)
+ (report (highlight (G_ " - ~h (~,1f%) were identical~%"))
matches (* 100. (/ matches total)))
- (report (G_ " - ~h (~,1f%) differed~%")
+ (report ((if (zero? discrepancies) good-news bad-news)
+ (G_ " - ~h (~,1f%) differed~%"))
discrepancies (* 100. (/ discrepancies total)))
(report (G_ " - ~h (~,1f%) were inconclusive~%")
inconclusive (* 100. (/ inconclusive total)))))