From mboxrd@z Thu Jan 1 00:00:00 1970 From: Robert Vollmert Subject: small hack to prettify output of list-installed Date: Fri, 19 Jul 2019 09:46:15 +0200 Message-ID: Mime-Version: 1.0 (Mac OS X Mail 12.4 \(3445.104.11\)) Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Return-path: Received: from eggs.gnu.org ([2001:470:142:3::10]:39030) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hoNaw-0006lw-N2 for guix-devel@gnu.org; Fri, 19 Jul 2019 03:46:23 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hoNav-0003WV-IZ for guix-devel@gnu.org; Fri, 19 Jul 2019 03:46:22 -0400 Received: from mx2.mailbox.org ([80.241.60.215]:31890) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hoNav-0003Un-7w for guix-devel@gnu.org; Fri, 19 Jul 2019 03:46:21 -0400 Received: from smtp1.mailbox.org (smtp1.mailbox.org [80.241.60.240]) (using TLSv1.2 with cipher ECDHE-RSA-CHACHA20-POLY1305 (256/256 bits)) (No client certificate requested) by mx2.mailbox.org (Postfix) with ESMTPS id 556BAA01EA for ; Fri, 19 Jul 2019 09:46:19 +0200 (CEST) Received: from smtp1.mailbox.org ([80.241.60.240]) by hefe.heinlein-support.de (hefe.heinlein-support.de [91.198.250.172]) (amavisd-new, port 10030) with ESMTP id C2_tH56_90-4 for ; Fri, 19 Jul 2019 09:46:16 +0200 (CEST) List-Id: "Development of GNU Guix and the GNU System distribution." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-devel-bounces+gcggd-guix-devel=m.gmane.org@gnu.org Sender: "Guix-devel" To: guix-devel@gnu.org Hi, here=E2=80=99s a small patch that calls =E2=80=9Ccolumn -t=E2=80=9D on = the output of `guix package --list-installed`. Probably not suitable for inclusion since I assume the guix scripts shouldn=E2=80=99t depend on `util-linux`, but I find it quite nice to have, so maybe it=E2=80=99s useful to someone else. Robert =46rom 1c6bf7e150445126448f1d5be4822889961f451f Mon Sep 17 00:00:00 2001 From: Robert Vollmert Date: Fri, 19 Jul 2019 09:40:53 +0200 Subject: [PATCH] columnize list-installed and list-available --- guix/scripts/package.scm | 49 ++++++++++++++++++++++++---------------- 1 file changed, 30 insertions(+), 19 deletions(-) diff --git a/guix/scripts/package.scm b/guix/scripts/package.scm index a43c96516f..ee7d16062b 100644 --- a/guix/scripts/package.scm +++ b/guix/scripts/package.scm @@ -43,6 +43,7 @@ #:select (directory-exists? mkdir-p)) #:use-module (ice-9 format) #:use-module (ice-9 match) + #:use-module (ice-9 popen) #:use-module (ice-9 regex) #:use-module (ice-9 vlist) #:use-module (srfi srfi-1) @@ -55,6 +56,7 @@ #:autoload (gnu packages base) (canonical-package) #:autoload (gnu packages guile) (guile-2.2) #:autoload (gnu packages bootstrap) (%bootstrap-guile) + #:autoload (gnu packages linux) (util-linux) #:export (build-and-use-profile delete-generations delete-matching-generations @@ -654,6 +656,11 @@ doesn't need it." ;;; Queries and actions. ;;; =20 +(define (columnize thunk) + (let ((port (open-output-pipe "column -t"))) + (with-output-to-port port thunk) + (close-pipe port))) + (define (process-query opts) "Process any query specified by OPTS. Return #t when a query was = actually processed, #f otherwise." @@ -703,15 +710,17 @@ processed, #f otherwise." (manifest (profile-manifest profile)) (installed (manifest-entries manifest))) (leave-on-EPIPE - (for-each (match-lambda - (($ name version output path _) - (when (or (not regexp) - (regexp-exec regexp name)) - (format #t "~a\t~a\t~a\t~a~%" - name (or version "?") output path)))) - - ;; Show most recently installed packages last. - (reverse installed))) + (columnize + (lambda () + (for-each (match-lambda + (($ name version output path = _) + (when (or (not regexp) + (regexp-exec regexp name)) + (format #t "~a\t~a\t~a\t~a~%" + name (or version "?") output = path)))) + + ;; Show most recently installed packages last. + (reverse installed))))) #t)) =20 (('list-available regexp) @@ -734,16 +743,18 @@ processed, #f otherwise." result)) '()))) (leave-on-EPIPE - (for-each (match-lambda - ((name version outputs location) - (format #t "~a\t~a\t~a\t~a~%" - name version - (string-join outputs ",") - (location->string location)))) - (sort available - (match-lambda* - (((name1 . _) (name2 . _)) - (stringstring location)))) + (sort available + (match-lambda* + (((name1 . _) (name2 . _)) + (string