unofficial mirror of guix-patches@gnu.org 
 help / color / mirror / code / Atom feed
* [bug#69413] [PATCH] guix: pull: prettify channel listing during pull operation.
@ 2024-02-26 19:16 Dale Mellor
  2024-03-09 18:22 ` [bug#69413] [PATCH v2] guix: scripts: " Dale Mellor
  0 siblings, 1 reply; 2+ messages in thread
From: Dale Mellor @ 2024-02-26 19:16 UTC (permalink / raw)
  To: 69413

  * 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


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* [bug#69413] [PATCH v2] guix: scripts: pull: prettify channel listing during pull operation.
  2024-02-26 19:16 [bug#69413] [PATCH] guix: pull: prettify channel listing during pull operation Dale Mellor
@ 2024-03-09 18:22 ` Dale Mellor
  0 siblings, 0 replies; 2+ messages in thread
From: Dale Mellor @ 2024-03-09 18:22 UTC (permalink / raw)
  To: 69413; +Cc: black-hole

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(-)

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





^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2024-03-09 18:23 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-02-26 19:16 [bug#69413] [PATCH] guix: pull: prettify channel listing during pull operation Dale Mellor
2024-03-09 18:22 ` [bug#69413] [PATCH v2] guix: scripts: " Dale Mellor

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/guix.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).