[PATCH] guix: pull: prettify channel listing during pull operation.

  • Open
  • quality assurance status badge
Details
One participant
  • Dale Mellor
Owner
unassigned
Submitted by
Dale Mellor
Severity
normal
D
D
Dale Mellor wrote on 26 Feb 20:16 +0100
(name . guix-patches)(address . guix-patches@gnu.org)
3f64ef9053ccb085b479fc0ece69caece1f72ee2.camel@rdmp.org
  * 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(-)

Toggle diff (59 lines)
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
D
D
Dale Mellor wrote on 9 Mar 19:22 +0100
[PATCH v2] guix: scripts: pull: prettify channel listing during pull operation.
(address . 69413@debbugs.gnu.org)
20240309182223.2103178-1-guix-devel-0brg6b@rdmp.org
From: Dale Mellor <black-hole@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(-)

Toggle diff (59 lines)
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
?
Your comment

Commenting via the web interface is currently disabled.

To comment on this conversation send an email to 69413@debbugs.gnu.org

To respond to this issue using the mumi CLI, first switch to it
mumi current 69413
Then, you may apply the latest patchset in this issue (with sign off)
mumi am -- -s
Or, compose a reply to this issue
mumi compose
Or, send patches to this issue
mumi send-email *.patch