From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:51432) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gPTKW-0002Gv-3V for guix-patches@gnu.org; Wed, 21 Nov 2018 09:18:15 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gPTKM-0004Pg-MW for guix-patches@gnu.org; Wed, 21 Nov 2018 09:18:08 -0500 Received: from debbugs.gnu.org ([208.118.235.43]:33728) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gPTKM-0004PG-Go for guix-patches@gnu.org; Wed, 21 Nov 2018 09:18:02 -0500 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1gPTKL-0000gF-PN for guix-patches@gnu.org; Wed, 21 Nov 2018 09:18:01 -0500 Subject: [bug#33448] [PATCH 1/3] describe: Use a procedure to format output. References: <20181120222616.3941-1-go.wigust@gmail.com> In-Reply-To: <20181120222616.3941-1-go.wigust@gmail.com> Resent-Message-ID: From: Oleg Pykhalov Date: Wed, 21 Nov 2018 17:17:13 +0300 Message-Id: <20181121141715.16417-1-go.wigust@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+kyle=kyleam.com@gnu.org Sender: "Guix-patches" To: 33448@debbugs.gnu.org * guix/channels.scm (channel->sexp): New procedure. * guix/scripts/describe.scm (display-checkout-info, display-profile-info): Use this. --- guix/channels.scm | 9 +++++++ guix/scripts/describe.scm | 57 ++++++++++++++++++++------------------- 2 files changed, 38 insertions(+), 28 deletions(-) diff --git a/guix/channels.scm b/guix/channels.scm index 82389eb58..bfdbf470b 100644 --- a/guix/channels.scm +++ b/guix/channels.scm @@ -39,6 +39,7 @@ channel-commit channel-location + channel->sexp %default-channels channel-instance? @@ -85,6 +86,14 @@ "Return true if CHANNEL is the 'guix' channel." (eq? 'guix (channel-name channel))) +(define channel->sexp + (match-lambda + (($ name url branch commit location) + `(channel + (name ,name) + (url ,url) + (commit ,commit))))) + (define-record-type (channel-instance channel commit checkout) channel-instance? diff --git a/guix/scripts/describe.scm b/guix/scripts/describe.scm index d817d7f7c..6a30d19b1 100644 --- a/guix/scripts/describe.scm +++ b/guix/scripts/describe.scm @@ -18,6 +18,7 @@ (define-module (guix scripts describe) #:use-module ((guix ui) #:hide (display-profile-content)) + #:use-module (guix channels) #:use-module (guix scripts) #:use-module (guix describe) #:use-module (guix profiles) @@ -104,10 +105,9 @@ within a Git checkout." (format #t (G_ " branch: ~a~%") (reference-shorthand head)) (format #t (G_ " commit: ~a~%") commit)) ('channels - (pretty-print `(list (channel - (name 'guix) - (url ,(dirname directory)) - (commit ,commit)))))) + (pretty-print (channel->sexp (channel (name 'guix) + (url (dirname directory)) + (commit commit)))))) (display-package-search-path fmt))) (define (display-profile-info profile fmt) @@ -116,34 +116,35 @@ in the format specified by FMT." (define number (generation-number profile)) + (define (channels) + (map (lambda (entry) + (match (assq 'source (manifest-entry-properties entry)) + (('source ('repository ('version 0) + ('url url) + ('branch branch) + ('commit commit) + _ ...)) + (channel (name (string->symbol (manifest-entry-name entry))) + (url url) + (commit commit))) + + ;; Pre-0.15.0 Guix does not provide that information, + ;; so there's not much we can do in that case. + (_ '???))) + + ;; Show most recently installed packages last. + (reverse + (manifest-entries + (profile-manifest + (if (zero? number) + profile + (generation-file-name profile number))))))) + (match fmt ('human (display-profile-content profile number)) ('channels - (pretty-print - `(list ,@(map (lambda (entry) - (match (assq 'source (manifest-entry-properties entry)) - (('source ('repository ('version 0) - ('url url) - ('branch branch) - ('commit commit) - _ ...)) - `(channel (name ',(string->symbol - (manifest-entry-name entry))) - (url ,url) - (commit ,commit))) - - ;; Pre-0.15.0 Guix does not provide that information, - ;; so there's not much we can do in that case. - (_ '???))) - - ;; Show most recently installed packages last. - (reverse - (manifest-entries - (profile-manifest - (if (zero? number) - profile - (generation-file-name profile number)))))))))) + (pretty-print (map channel->sexp (channels))))) (display-package-search-path fmt)) -- 2.19.1