From patchwork Sat Mar 9 18:22:23 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dale Mellor X-Patchwork-Id: 61579 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 19A1C27BBEA; Sat, 9 Mar 2024 18:23:52 +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 62AB127BBE2 for ; Sat, 9 Mar 2024 18:23:51 +0000 (GMT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rj1M9-0006bB-S5; Sat, 09 Mar 2024 13:23:37 -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 1rj1M3-0006YX-Ur for guix-patches@gnu.org; Sat, 09 Mar 2024 13:23:32 -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 1rj1M1-0001QC-7R for guix-patches@gnu.org; Sat, 09 Mar 2024 13:23:31 -0500 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1rj1MX-0005z3-UF for guix-patches@gnu.org; Sat, 09 Mar 2024 13:24:01 -0500 X-Loop: help-debbugs@gnu.org Subject: [bug#69413] [PATCH v2] guix: scripts: pull: prettify channel listing during pull operation. Resent-From: Dale Mellor Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Sat, 09 Mar 2024 18:24:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 69413 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 69413@debbugs.gnu.org Cc: black-hole@rdmp.org X-Debbugs-Original-Cc: Dale Mellor , guix-patches@gnu.org Received: via spool by submit@debbugs.gnu.org id=B.171000859022917 (code B ref -1); Sat, 09 Mar 2024 18:24:01 +0000 Received: (at submit) by debbugs.gnu.org; 9 Mar 2024 18:23:10 +0000 Received: from localhost ([127.0.0.1]:34770 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rj1Lh-0005xT-Ol for submit@debbugs.gnu.org; Sat, 09 Mar 2024 13:23:10 -0500 Received: from lists.gnu.org ([209.51.188.17]:42196) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rj1Le-0005xE-6l for submit@debbugs.gnu.org; Sat, 09 Mar 2024 13:23:06 -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 1rj1L7-0006Oc-2E for guix-patches@gnu.org; Sat, 09 Mar 2024 13:22:33 -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 1rj1L5-0001BV-Fn for guix-patches@gnu.org; Sat, 09 Mar 2024 13:22:32 -0500 Received: from [127.0.0.1] (helo=localhost.localdomain) by rdmp.org with esmtp (Exim 4.96.1) (envelope-from ) id 1rj1KQ-0005Op-2R; Sat, 09 Mar 2024 18:22:27 +0000 From: Dale Mellor Date: Sat, 9 Mar 2024 18:22:23 +0000 Message-ID: <20240309182223.2103178-1-guix-devel-0brg6b@rdmp.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <3f64ef9053ccb085b479fc0ece69caece1f72ee2.camel@rdmp.org> References: <3f64ef9053ccb085b479fc0ece69caece1f72ee2.camel@rdmp.org> MIME-Version: 1.0 X-Host-Lookup-Failed: Reverse DNS lookup failed for 195.15.247.228 (failed) Received-SPF: pass client-ip=195.15.247.228; envelope-from=guix-devel-0brg6b@rdmp.org; helo=rdmp.org X-Spam_score_int: -10 X-Spam_score: -1.1 X-Spam_bar: - X-Spam_report: (-1.1 / 5.0 requ) BAYES_00=-1.9, RDNS_NONE=0.793, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, 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: , 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 From: Dale Mellor * 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)