guix-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

03/03: describe: Add recutils format.


From: guix-commits
Subject: 03/03: describe: Add recutils format.
Date: Thu, 22 Nov 2018 13:21:06 -0500 (EST)

wigust pushed a commit to branch master
in repository guix.

commit 85e9c4b91990008f2b6b07c5de6f14427d7c3a06
Author: Oleg Pykhalov <address@hidden>
Date:   Wed Nov 21 16:35:38 2018 +0300

    describe: Add recutils format.
    
    * guix/scripts/describe.scm (channel->recutils): New procedure.
    (display-checkout-info, display-profile-info): Use this.
    (%options): Add 'recutils' option.
    * doc/guix.texi (Invoking guix describe): Document this.
---
 doc/guix.texi             |  4 +++-
 guix/scripts/describe.scm | 23 ++++++++++++++++++++---
 2 files changed, 23 insertions(+), 4 deletions(-)

diff --git a/doc/guix.texi b/doc/guix.texi
index 3413eb3..44594d1 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;
address@hidden recutils
+produce a list of channel specifications in Recutils format.
 @end table
 
 @item address@hidden
diff --git a/guix/scripts/describe.scm b/guix/scripts/describe.scm
index 0bfd983..98be4ee 100644
--- a/guix/scripts/describe.scm
+++ b/guix/scripts/describe.scm
@@ -41,7 +41,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
@@ -98,6 +98,11 @@ Display information about the channels currently in use.\n"))
                       (url . ,(channel-url channel))
                       (commit . ,(channel-commit channel)))))
 
+(define (channel->recutils channel port)
+  (format port "name: ~a~%" (channel-name channel))
+  (format port "url: ~a~%" (channel-url channel))
+  (format port "commit: ~a~%" (channel-commit channel)))
+
 (define* (display-checkout-info fmt #:optional directory)
   "Display information about the current checkout according to FMT, a symbol
 denoting the requested format.  Exit if the current directory does not lie
@@ -125,7 +130,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))
+                          (current-output-port))))
     (display-package-search-path fmt)))
 
 (define (display-profile-info profile fmt)
@@ -166,7 +176,14 @@ in the format specified by FMT."
     ('channels
      (pretty-print `(list ,@(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))
 
 



reply via email to

[Prev in Thread] Current Thread [Next in Thread]