pull: Factorize pretty-printing for new/upgraded package lists.

* guix/scripts/pull.scm (display-new/upgraded-packages)[pretty]: New
procedure.
Use it.
This commit is contained in:
Ludovic Courtès 2019-03-28 15:55:47 +01:00
parent f2bf0407de
commit 9f4169f6c8
No known key found for this signature in database
GPG Key ID: 090B11993D9AEBB5
1 changed files with 10 additions and 9 deletions

View File

@ -382,6 +382,11 @@ of packages upgraded in ALIST2."
"Given the two package name/version alists ALIST1 and ALIST2, display the "Given the two package name/version alists ALIST1 and ALIST2, display the
list of new and upgraded packages going from ALIST1 to ALIST2. When ALIST1 list of new and upgraded packages going from ALIST1 to ALIST2. When ALIST1
and ALIST2 differ, display HEADING upfront." and ALIST2 differ, display HEADING upfront."
(define (pretty str column)
(indented-string (fill-paragraph str (- (%text-width) 4)
column)
4))
(let-values (((new upgraded) (new/upgraded-packages alist1 alist2))) (let-values (((new upgraded) (new/upgraded-packages alist1 alist2)))
(unless (and (null? new) (null? upgraded)) (unless (and (null? new) (null? upgraded))
(display heading)) (display heading))
@ -392,21 +397,17 @@ and ALIST2 differ, display HEADING upfront."
(format #t (N_ " ~h new package: ~a~%" (format #t (N_ " ~h new package: ~a~%"
" ~h new packages: ~a~%" count) " ~h new packages: ~a~%" count)
count count
(indented-string (pretty (string-join (sort (map first new) string<?)
(fill-paragraph (string-join (sort (map first new) string<?) ", ")
", ") 30))))
(- (%text-width) 4) 30)
4))))
(match (length upgraded) (match (length upgraded)
(0 #t) (0 #t)
(count (count
(format #t (N_ " ~h package upgraded: ~a~%" (format #t (N_ " ~h package upgraded: ~a~%"
" ~h packages upgraded: ~a~%" count) " ~h packages upgraded: ~a~%" count)
count count
(indented-string (pretty (string-join (sort upgraded string<?) ", ")
(fill-paragraph (string-join (sort upgraded string<?) ", ") 35))))))
(- (%text-width) 4) 35)
4))))))
(define (display-profile-content-diff profile gen1 gen2) (define (display-profile-content-diff profile gen1 gen2)
"Display the changes in PROFILE GEN2 compared to generation GEN1." "Display the changes in PROFILE GEN2 compared to generation GEN1."