GNU bug report logs - #69413
[PATCH] guix: pull: prettify channel listing during pull operation.

Previous Next

Package: guix-patches;

Reported by: guix-devel-0brg6b <at> rdmp.org

Date: Mon, 26 Feb 2024 19:17:02 UTC

Severity: normal

Tags: patch

To reply to this bug, email your comments to 69413 AT debbugs.gnu.org.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to guix-patches <at> gnu.org:
bug#69413; Package guix-patches. (Mon, 26 Feb 2024 19:17:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to guix-devel-0brg6b <at> rdmp.org:
New bug report received and forwarded. Copy sent to guix-patches <at> gnu.org. (Mon, 26 Feb 2024 19:17:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Dale Mellor <guix-devel-0brg6b <at> rdmp.org>
To: guix-patches <guix-patches <at> gnu.org>
Subject: [PATCH] guix: pull: prettify channel listing during pull operation.
Date: Mon, 26 Feb 2024 19:16:15 +0000
  * guix/scripts/pull.scm (guix-pull): use pretty-print-table from utils

  * guix/utils.scm: give pretty-print-table optional argument to specify
                    output stream.
---
 guix/scripts/pull.scm | 24 +++++++++++++-----------
 guix/utils.scm        |  4 ++--
 2 files changed, 15 insertions(+), 13 deletions(-)

diff --git a/guix/scripts/pull.scm b/guix/scripts/pull.scm
index 58d3cd7e83c..c5296cf80a1 100644
--- a/guix/scripts/pull.scm
+++ b/guix/scripts/pull.scm
@@ -882,17 +882,19 @@ (define (no-arguments arg _)
                            (N_ "Building from this channel:~%"
                                "Building from these channels:~%"
                                (length instances)))
-                   (for-each (lambda (instance)
-                               (let ((channel
-                                      (channel-instance-channel instance)))
-                                 (format (current-error-port)
-                                         "  ~10a~a\t~a~%"
-                                         (channel-name channel)
-                                         (channel-url channel)
-                                         (string-take
-                                          (channel-instance-commit instance)
-                                          7))))
-                             instances)
+                   (pretty-print-table
+                    (map-in-order (lambda (instance)
+                                    (let ((channel
+                                           (channel-instance-channel instance)))
+                                      (list (symbol->string (channel-name channel))
+                                            (channel-url channel)
+                                            (string-take
+                                             (channel-instance-commit instance)
+                                             7))))
+                                  instances)
+                    #:max-column-width 100   ;; URLs can be long.
+                    #:left-pad 2
+                    #:output (current-error-port))
                    (parameterize ((%guile-for-build
                                    (package-derivation
                                     store
diff --git a/guix/utils.scm b/guix/utils.scm
index 29ad09d9f72..39a34134457 100644
--- a/guix/utils.scm
+++ b/guix/utils.scm
@@ -1192,7 +1192,7 @@ (define* (string-closest trial tests #:key (threshold 3))
 ;;; Prettified output.
 ;;;
 
-(define* (pretty-print-table rows #:key (max-column-width 20) (left-pad 0))
+(define* (pretty-print-table rows #:key (max-column-width 20) (left-pad 0) (output #t))
   "Print ROWS in neat columns.  All rows should be lists of strings and each
 row should have the same length.  The columns are separated by a tab
 character, and aligned using spaces.  The maximum width of each column is
@@ -1211,7 +1211,7 @@ (define* (pretty-print-table rows #:key (max-column-width 20) (left-pad 0))
                               (map (cut min <> max-column-width)
                                    column-widths)))
          (fmt (string-append (string-join column-formats "\t") "\t~a")))
-    (for-each (cut format #t "~v_~?~%" left-pad fmt <>) rows)))
+    (for-each (cut format output "~v_~?~%" left-pad fmt <>) rows)))
 
 ;;; Local Variables:
 ;;; eval: (put 'call-with-progress-reporter 'scheme-indent-function 1)
-- 
2.41.0


Information forwarded to guix-patches <at> gnu.org:
bug#69413; Package guix-patches. (Sat, 09 Mar 2024 18:24:01 GMT) Full text and rfc822 format available.

Message #8 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Dale Mellor <guix-devel-0brg6b <at> rdmp.org>
To: 69413 <at> debbugs.gnu.org
Cc: Dale Mellor <black-hole <at> rdmp.org>, guix-patches <at> gnu.org
Subject: [PATCH v2] guix: scripts: pull: prettify channel listing during pull
 operation.
Date: Sat,  9 Mar 2024 18:22:23 +0000
From: Dale Mellor <black-hole <at> rdmp.org>

  * guix/scripts/pull.scm: use pretty-print-table from utils

  * guix/utils.scm: give pretty-print-table optional argument to specify
                    output stream.
---
 guix/scripts/pull.scm | 24 +++++++++++++-----------
 guix/utils.scm        |  4 ++--
 2 files changed, 15 insertions(+), 13 deletions(-)

diff --git a/guix/scripts/pull.scm b/guix/scripts/pull.scm
index 58d3cd7e83c..c5296cf80a1 100644
--- a/guix/scripts/pull.scm
+++ b/guix/scripts/pull.scm
@@ -882,17 +882,19 @@ (define (no-arguments arg _)
                            (N_ "Building from this channel:~%"
                                "Building from these channels:~%"
                                (length instances)))
-                   (for-each (lambda (instance)
-                               (let ((channel
-                                      (channel-instance-channel instance)))
-                                 (format (current-error-port)
-                                         "  ~10a~a\t~a~%"
-                                         (channel-name channel)
-                                         (channel-url channel)
-                                         (string-take
-                                          (channel-instance-commit instance)
-                                          7))))
-                             instances)
+                   (pretty-print-table
+                    (map-in-order (lambda (instance)
+                                    (let ((channel
+                                           (channel-instance-channel instance)))
+                                      (list (symbol->string (channel-name channel))
+                                            (channel-url channel)
+                                            (string-take
+                                             (channel-instance-commit instance)
+                                             7))))
+                                  instances)
+                    #:max-column-width 100   ;; URLs can be long.
+                    #:left-pad 2
+                    #:output (current-error-port))
                    (parameterize ((%guile-for-build
                                    (package-derivation
                                     store
diff --git a/guix/utils.scm b/guix/utils.scm
index 29ad09d9f72..39a34134457 100644
--- a/guix/utils.scm
+++ b/guix/utils.scm
@@ -1192,7 +1192,7 @@ (define* (string-closest trial tests #:key (threshold 3))
 ;;; Prettified output.
 ;;;
 
-(define* (pretty-print-table rows #:key (max-column-width 20) (left-pad 0))
+(define* (pretty-print-table rows #:key (max-column-width 20) (left-pad 0) (output #t))
   "Print ROWS in neat columns.  All rows should be lists of strings and each
 row should have the same length.  The columns are separated by a tab
 character, and aligned using spaces.  The maximum width of each column is
@@ -1211,7 +1211,7 @@ (define* (pretty-print-table rows #:key (max-column-width 20) (left-pad 0))
                               (map (cut min <> max-column-width)
                                    column-widths)))
          (fmt (string-append (string-join column-formats "\t") "\t~a")))
-    (for-each (cut format #t "~v_~?~%" left-pad fmt <>) rows)))
+    (for-each (cut format output "~v_~?~%" left-pad fmt <>) rows)))
 
 ;;; Local Variables:
 ;;; eval: (put 'call-with-progress-reporter 'scheme-indent-function 1)
-- 
2.41.0





Information forwarded to guix-patches <at> gnu.org:
bug#69413; Package guix-patches. (Sat, 09 Mar 2024 18:24:02 GMT) Full text and rfc822 format available.

This bug report was last modified 55 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.