[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
03/06: pull: Truncate the list of packages displayed on completion.
From: |
guix-commits |
Subject: |
03/06: pull: Truncate the list of packages displayed on completion. |
Date: |
Thu, 28 Mar 2019 18:07:57 -0400 (EDT) |
civodul pushed a commit to branch master
in repository guix.
commit 539af7f257eea291b1e6ffbfdcaeee9fde9bffe5
Author: Ludovic Courtès <address@hidden>
Date: Thu Mar 28 16:17:11 2019 +0100
pull: Truncate the list of packages displayed on completion.
Previously, if you'd run 'guix pull' after a couple of weeks, it would
fill your screen with package names, which is unhelpful.
* guix/scripts/pull.scm (ellipsis): New procedure.
(display-new/upgraded-packages): Add #:concise?.
[list->enumeration]: New procedure.
Use it instead of 'string-join'.
(display-profile-news): Pass #:concise? #t.
---
guix/scripts/pull.scm | 27 ++++++++++++++++++++++-----
1 file changed, 22 insertions(+), 5 deletions(-)
diff --git a/guix/scripts/pull.scm b/guix/scripts/pull.scm
index e06ec2f..2aaf1cc 100644
--- a/guix/scripts/pull.scm
+++ b/guix/scripts/pull.scm
@@ -181,6 +181,7 @@ Download and deploy the latest version of Guix.\n"))
(new (profile-package-alist
(generation-file-name profile current))))
(display-new/upgraded-packages old new
+ #:concise? #t
#:heading (G_ "New in this
revision:\n"))))
(_ #t)))
@@ -377,16 +378,33 @@ of packages upgraded in ALIST2."
alist2)))
(values new upgraded)))
+(define* (ellipsis #:optional (port (current-output-port)))
+ "Return HORIZONTAL ELLIPSIS three dots if PORT's encoding cannot represent
+it."
+ (match (port-encoding port)
+ ("UTF-8" "…")
+ (_ "...")))
+
(define* (display-new/upgraded-packages alist1 alist2
- #:key (heading ""))
+ #:key (heading "") concise?)
"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
-and ALIST2 differ, display HEADING upfront."
+and ALIST2 differ, display HEADING upfront. When CONCISE? is true, do not
+display long package lists that would fill the user's screen."
(define (pretty str column)
(indented-string (fill-paragraph str (- (%text-width) 4)
column)
4))
+ (define list->enumeration
+ (if concise?
+ (lambda* (lst #:optional (max 12))
+ (if (> (length lst) max)
+ (string-append (string-join (take lst max) ", ")
+ ", " (ellipsis))
+ (string-join lst ", ")))
+ (cut string-join <> ", ")))
+
(let-values (((new upgraded) (new/upgraded-packages alist1 alist2)))
(unless (and (null? new) (null? upgraded))
(display heading))
@@ -397,8 +415,7 @@ and ALIST2 differ, display HEADING upfront."
(format #t (N_ " ~h new package: ~a~%"
" ~h new packages: ~a~%" count)
count
- (pretty (string-join (sort (map first new) string<?)
- ", ")
+ (pretty (list->enumeration (sort (map first new) string<?))
30))))
(match (length upgraded)
(0 #t)
@@ -406,7 +423,7 @@ and ALIST2 differ, display HEADING upfront."
(format #t (N_ " ~h package upgraded: ~a~%"
" ~h packages upgraded: ~a~%" count)
count
- (pretty (string-join (sort upgraded string<?) ", ")
+ (pretty (list->enumeration (sort upgraded string<?))
35))))))
(define (display-profile-content-diff profile gen1 gen2)
- branch master updated (e8cfce4 -> 357b287), guix-commits, 2019/03/28
- 06/06: services: desktop: Switch to GDM., guix-commits, 2019/03/28
- 05/06: system: Fix typo in desktop example., guix-commits, 2019/03/28
- 04/06: gnu: ratpoison: Provide a .desktop file with an absolute file name., guix-commits, 2019/03/28
- 02/06: pull: Factorize pretty-printing for new/upgraded package lists., guix-commits, 2019/03/28
- 03/06: pull: Truncate the list of packages displayed on completion.,
guix-commits <=
- 01/06: packages: Reintroduce 'find-newest-available-packages'., guix-commits, 2019/03/28