From: Oleg Pykhalov <go.wigust@gmail.com>
To: 33448@debbugs.gnu.org
Subject: [bug#33448] [PATCH 3/3] describe: Add recutils format.
Date: Wed, 21 Nov 2018 17:17:15 +0300 [thread overview]
Message-ID: <20181121141715.16417-3-go.wigust@gmail.com> (raw)
In-Reply-To: <20181121141715.16417-1-go.wigust@gmail.com>
* 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
+ (($ <channel> 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-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))
\f
--
2.19.1
next prev parent reply other threads:[~2018-11-21 14:18 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-11-20 22:26 [bug#33448] [PATCH] describe: Fix 'format' option Oleg Pykhalov
2018-11-21 7:00 ` [bug#33448] [PATCH] describe: Add json format Oleg Pykhalov
2018-11-21 10:53 ` Ludovic Courtès
2018-11-21 14:10 ` Oleg Pykhalov
2018-11-21 21:36 ` Ludovic Courtès
2018-11-21 10:47 ` [bug#33448] [PATCH] describe: Fix 'format' option Ludovic Courtès
2018-11-21 11:46 ` Oleg Pykhalov
2018-11-21 14:17 ` [bug#33448] [PATCH 1/3] describe: Use a procedure to format output Oleg Pykhalov
2018-11-21 14:17 ` [bug#33448] [PATCH 2/3] describe: Add json format Oleg Pykhalov
2018-11-21 21:33 ` Ludovic Courtès
2018-11-22 12:54 ` Oleg Pykhalov
2018-11-22 16:53 ` Ludovic Courtès
2018-11-22 18:23 ` Oleg Pykhalov
2018-11-21 14:17 ` Oleg Pykhalov [this message]
2018-11-21 21:34 ` [bug#33448] [PATCH 3/3] describe: Add recutils format Ludovic Courtès
2018-11-21 21:31 ` [bug#33448] [PATCH 1/3] describe: Use a procedure to format output Ludovic Courtès
2018-11-22 12:54 ` Oleg Pykhalov
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20181121141715.16417-3-go.wigust@gmail.com \
--to=go.wigust@gmail.com \
--cc=33448@debbugs.gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/guix.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.