[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: guix pull package output truncated
From: |
Ludovic Courtès |
Subject: |
Re: guix pull package output truncated |
Date: |
Thu, 18 Apr 2019 17:25:43 +0200 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/26.2 (gnu/linux) |
Howdy!
Tobias Geerinckx-Rice <address@hidden> skribis:
> Ludovic Courtès wrote:
>> There’s currently no flag to change this behavior. Instead, you
>> have to
>> run ‘guix pull -l’ but it’s arguably not very convenient.
>>
>> Perhaps we could add an environment variable specifying whether/how
>> to
>> truncate? I’d keep the default as it is now.
>
> AIUC, this list of changes is displayed once and then ‘lost’ (to the
> average user) when they clear their screen, right?
Yup.
> Or is there a command that returns this nice list of differences
> between two guix-profiles that we could suggest running when the
> default is truncated? It could default to current and current-1, and
> would solve both (minor) irritations.
I think that’s a good idea.
What about a ‘--news’ option along with a hint as in the attached patch?
--8<---------------cut here---------------start------------->8---
$ guix pull --news
New in this revision:
9 new packages: cl-log4cl, ecl-log4cl, emacs-ace-jump-mode, emacs-ace-link,
libomp, lucene++,
mate-power-manager, poedit, sbcl-log4cl
63 packages upgraded: address@hidden, address@hidden, address@hidden,
address@hidden, address@hidden,
address@hidden, address@hidden, address@hidden, address@hidden,
address@hidden, address@hidden,
address@hidden, address@hidden, address@hidden, address@hidden,
address@hidden, address@hidden, address@hidden, address@hidden,
address@hidden, address@hidden,
address@hidden, address@hidden, address@hidden, address@hidden,
address@hidden,
address@hidden, address@hidden, address@hidden, address@hidden,
address@hidden, address@hidden, address@hidden,
address@hidden, address@hidden, address@hidden, address@hidden,
address@hidden, address@hidden, address@hidden,
address@hidden, address@hidden, address@hidden, address@hidden,
address@hidden,
address@hidden, address@hidden, address@hidden, address@hidden,
address@hidden, address@hidden,
address@hidden, address@hidden, address@hidden, address@hidden,
address@hidden, address@hidden,
address@hidden, address@hidden, address@hidden, address@hidden,
address@hidden,
address@hidden
--8<---------------cut here---------------end--------------->8---
I’ll push it with documentation if there are no objections.
Thanks!
Ludo’.
diff --git a/guix/scripts/pull.scm b/guix/scripts/pull.scm
index 71e13686c0..fe6ebb1656 100644
--- a/guix/scripts/pull.scm
+++ b/guix/scripts/pull.scm
@@ -117,6 +117,9 @@ Download and deploy the latest version of Guix.\n"))
(lambda (opt name arg result)
(cons `(query list-generations ,(or arg ""))
result)))
+ (option '(#\N "news") #f #f
+ (lambda (opt name arg result)
+ (cons '(query display-news) result)))
(option '("url") #t #f
(lambda (opt name arg result)
(alist-cons 'repository-url arg
@@ -162,25 +165,28 @@ Download and deploy the latest version of Guix.\n"))
(define indirect-root-added
(store-lift add-indirect-root))
-(define (display-profile-news profile)
+(define* (display-profile-news profile #:key concise?
+ current-is-newer?)
"Display what's up in PROFILE--new packages, and all that."
(match (memv (generation-number profile)
(reverse (profile-generations profile)))
((current previous _ ...)
- (newline)
- (let ((old (fold-available-packages
- (lambda* (name version result
- #:key supported? deprecated?
- #:allow-other-keys)
- (if (and supported? (not deprecated?))
- (alist-cons name version result)
- result))
- '()))
- (new (profile-package-alist
- (generation-file-name profile current))))
- (display-new/upgraded-packages old new
- #:concise? #t
- #:heading (G_ "New in this
revision:\n"))))
+ (let ((these (fold-available-packages
+ (lambda* (name version result
+ #:key supported? deprecated?
+ #:allow-other-keys)
+ (if (and supported? (not deprecated?))
+ (alist-cons name version result)
+ result))
+ '()))
+ (those (profile-package-alist
+ (generation-file-name profile current))))
+ (let ((old (if current-is-newer? those these))
+ (new (if current-is-newer? these those)))
+ (display-new/upgraded-packages old new
+ #:concise? concise?
+ #:heading
+ (G_ "New in this revision:\n")))))
(_ #t)))
(define* (build-and-install instances profile
@@ -196,7 +202,8 @@ true, display what would be built without actually building
it."
#:hooks %channel-profile-hooks
#:dry-run? dry-run?)
(munless dry-run?
- (return (display-profile-news profile))
+ (return (newline))
+ (return (display-profile-news profile #:concise? #t))
(match (which "guix")
(#f (return #f))
(str
@@ -394,9 +401,13 @@ display long package lists that would fill the user's
screen."
column)
4))
+ (define concise/max-item-count
+ ;; Maximum number of items to display when CONCISE? is true.
+ 12)
+
(define list->enumeration
(if concise?
- (lambda* (lst #:optional (max 12))
+ (lambda* (lst #:optional (max concise/max-item-count))
(if (> (length lst) max)
(string-append (string-join (take lst max) ", ")
", " (ellipsis))
@@ -404,10 +415,13 @@ display long package lists that would fill the user's
screen."
(cut string-join <> ", ")))
(let-values (((new upgraded) (new/upgraded-packages alist1 alist2)))
+ (define new-count (length new))
+ (define upgraded-count (length upgraded))
+
(unless (and (null? new) (null? upgraded))
(display heading))
- (match (length new)
+ (match new-count
(0 #t)
(count
(format #t (N_ " ~h new package: ~a~%"
@@ -415,14 +429,20 @@ display long package lists that would fill the user's
screen."
count
(pretty (list->enumeration (sort (map first new) string<?))
30))))
- (match (length upgraded)
+ (match upgraded-count
(0 #t)
(count
(format #t (N_ " ~h package upgraded: ~a~%"
" ~h packages upgraded: ~a~%" count)
count
(pretty (list->enumeration (sort upgraded string<?))
- 35))))))
+ 35))))
+
+ (when (and concise?
+ (or (> new-count concise/max-item-count)
+ (> upgraded-count concise/max-item-count)))
+ (display-hint (G_ "Run @command{guix pull --news} to view the complete
+list of package changes.")))))
(define (display-profile-content-diff profile gen1 gen2)
"Display the changes in PROFILE GEN2 compared to generation GEN1."
@@ -462,7 +482,12 @@ display long package lists that would fill the user's
screen."
(()
(exit 1))
((numbers ...)
- (list-generations profile numbers)))))))))
+ (list-generations profile numbers)))))))
+ (('display-news)
+ ;; Display profile news, with the understanding that this process
+ ;; represents the newest generation.
+ (display-profile-news profile
+ #:current-is-newer? #t))))
(define (channel-list opts)
"Return the list of channels to use. If OPTS specify a channel file,
Re: guix pull package output truncated, mikadoZero, 2019/04/17