From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:51455) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gPTKb-0002N6-Fv for guix-patches@gnu.org; Wed, 21 Nov 2018 09:18:18 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gPTKV-0004SV-5q for guix-patches@gnu.org; Wed, 21 Nov 2018 09:18:15 -0500 Received: from debbugs.gnu.org ([208.118.235.43]:33730) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gPTKO-0004Qf-Ku for guix-patches@gnu.org; Wed, 21 Nov 2018 09:18:06 -0500 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1gPTKM-0000gW-Pj for guix-patches@gnu.org; Wed, 21 Nov 2018 09:18:04 -0500 Subject: [bug#33448] [PATCH 3/3] describe: Add recutils format. Resent-Message-ID: From: Oleg Pykhalov Date: Wed, 21 Nov 2018 17:17:15 +0300 Message-Id: <20181121141715.16417-3-go.wigust@gmail.com> In-Reply-To: <20181121141715.16417-1-go.wigust@gmail.com> References: <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->recutils): New procedure. * guix/scripts/describe.scm (%options): Add 'recutils' option. (display-checkout-info, display-profile-info): Use 'channel->recutils'. * doc/guix.texi (Invoking guix describe): Document this. --- doc/guix.texi | 4 +++- guix/channels.scm | 8 ++++++++ guix/scripts/describe.scm | 18 +++++++++++++++--- 3 files changed, 26 insertions(+), 4 deletions(-) diff --git a/doc/guix.texi b/doc/guix.texi index 3413eb30f..44594d168 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -3276,7 +3276,9 @@ pull -C} or installed as @file{~/.config/guix/channels.scm} (@pxref{Invoking guix pull}); @item json @cindex JSON -produce a list of channel specifications in JSON format. +produce a list of channel specifications in JSON format; +@item recutils +produce a list of channel specifications in Recutils format. @end table @item --profile=@var{profile} diff --git a/guix/channels.scm b/guix/channels.scm index 9f2c9103e..ed9bc67c3 100644 --- a/guix/channels.scm +++ b/guix/channels.scm @@ -41,6 +41,7 @@ channel-location channel->json + channel->recutils channel->sexp %default-channels @@ -106,6 +107,13 @@ (cons 'url url) (cons 'commit commit)))))) +(define (channel->recutils c port) + (match c + (($ name url branch commit location) + (format port "name: ~a~%" name) + (format port "url: ~a~%" url) + (format port "commit: ~a~%" commit)))) + (define-record-type (channel-instance channel commit checkout) channel-instance? diff --git a/guix/scripts/describe.scm b/guix/scripts/describe.scm index d7e276769..90365b7ae 100644 --- a/guix/scripts/describe.scm +++ b/guix/scripts/describe.scm @@ -39,7 +39,7 @@ ;; Specifications of the command-line options. (list (option '(#\f "format") #t #f (lambda (opt name arg result) - (unless (member arg '("human" "channels" "json")) + (unless (member arg '("human" "channels" "json" "recutils")) (leave (G_ "~a: unsupported output format~%") arg)) (alist-cons 'format (string->symbol arg) result))) (option '(#\p "profile") #t #f @@ -112,7 +112,12 @@ within a Git checkout." (display (channel->json (channel (name 'guix) (url (dirname directory)) (commit commit)))) - (newline))) + (newline)) + ('recutils + (channel->recutils (channel (name 'guix) + (url (dirname directory)) + (commit commit)) + #t))) (display-package-search-path fmt))) (define (display-profile-info profile fmt) @@ -151,7 +156,14 @@ in the format specified by FMT." ('channels (pretty-print (map channel->sexp (channels)))) ('json - (format #t "[~a]~%" (string-join (map channel->json (channels)) ",")))) + (format #t "[~a]~%" (string-join (map channel->json (channels)) ","))) + ('recutils + (format #t "~{~a~%~}" + (map (lambda (channel) + (with-output-to-string + (lambda () + (channel->recutils channel (current-output-port))))) + (channels))))) (display-package-search-path fmt)) -- 2.19.1