From patchwork Mon Feb 26 19:16:15 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Dale Mellor X-Patchwork-Id: 61143 Return-Path: X-Original-To: patchwork@mira.cbaines.net Delivered-To: patchwork@mira.cbaines.net Received: by mira.cbaines.net (Postfix, from userid 113) id 64DF627BBEA; Mon, 26 Feb 2024 19:17:26 +0000 (GMT) X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-2.9 required=5.0 tests=BAYES_00,MAILING_LIST_MULTI, SPF_HELO_PASS autolearn=ham autolearn_force=no version=3.4.6 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mira.cbaines.net (Postfix) with ESMTPS id 2DA9727BBE2 for ; Mon, 26 Feb 2024 19:17:25 +0000 (GMT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1regT1-0008Hn-SQ; Mon, 26 Feb 2024 14:16:47 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1regSs-0008GQ-Dg for guix-patches@gnu.org; Mon, 26 Feb 2024 14:16:40 -0500 Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1regSr-0006jd-TA for guix-patches@gnu.org; Mon, 26 Feb 2024 14:16:38 -0500 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1regTG-0007qL-T5 for guix-patches@gnu.org; Mon, 26 Feb 2024 14:17:02 -0500 X-Loop: help-debbugs@gnu.org Subject: [bug#69413] [PATCH] guix: pull: prettify channel listing during pull operation. Resent-From: Dale Mellor Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Mon, 26 Feb 2024 19:17:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 69413 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 69413@debbugs.gnu.org X-Debbugs-Original-To: guix-patches Received: via spool by submit@debbugs.gnu.org id=B.170897501730123 (code B ref -1); Mon, 26 Feb 2024 19:17:02 +0000 Received: (at submit) by debbugs.gnu.org; 26 Feb 2024 19:16:57 +0000 Received: from localhost ([127.0.0.1]:59150 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1regT9-0007pi-6H for submit@debbugs.gnu.org; Mon, 26 Feb 2024 14:16:56 -0500 Received: from lists.gnu.org ([209.51.188.17]:42384) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1regT7-0007pV-7w for submit@debbugs.gnu.org; Mon, 26 Feb 2024 14:16:53 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1regSg-0008FA-Q0 for guix-patches@gnu.org; Mon, 26 Feb 2024 14:16:26 -0500 Received: from [195.15.247.228] (helo=rdmp.org) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1regSc-0006iB-Or for guix-patches@gnu.org; Mon, 26 Feb 2024 14:16:24 -0500 Received: from [127.0.0.1] (helo=[IPv6:::1]) by rdmp.org with esmtp (Exim 4.96.1) (envelope-from ) id 1regRs-0001aP-2I for guix-patches@gnu.org; Mon, 26 Feb 2024 19:16:16 +0000 Message-ID: <3f64ef9053ccb085b479fc0ece69caece1f72ee2.camel@rdmp.org> From: Dale Mellor Date: Mon, 26 Feb 2024 19:16:15 +0000 Organization: DM Bespoke Computer Solutions Ltd User-Agent: Evolution 3.46.4 MIME-Version: 1.0 X-Host-Lookup-Failed: Reverse DNS lookup failed for 195.15.247.228 (failed) Received-SPF: softfail client-ip=195.15.247.228; envelope-from=guix-devel-0brg6b@rdmp.org; helo=rdmp.org X-Spam_score_int: 3 X-Spam_score: 0.3 X-Spam_bar: / X-Spam_report: (0.3 / 5.0 requ) BAYES_00=-1.9, RDNS_NONE=0.793, SPF_HELO_SOFTFAIL=0.732, SPF_SOFTFAIL=0.665, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: guix-devel-0brg6b@rdmp.org Errors-To: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org Sender: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org X-getmail-retrieved-from-mailbox: Patches * 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)