guix-commits
[Top][All Lists]
Advanced

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

01/03: ui: 'package->recutils' takes #:extra-fields.


From: Ludovic Courtès
Subject: 01/03: ui: 'package->recutils' takes #:extra-fields.
Date: Tue, 13 Jun 2017 17:22:41 -0400 (EDT)

civodul pushed a commit to branch master
in repository guix.

commit 4ee79f22f5379b201eabca94c3ab34bb00a8a8b0
Author: Ludovic Courtès <address@hidden>
Date:   Tue Jun 13 18:09:30 2017 +0200

    ui: 'package->recutils' takes #:extra-fields.
    
    * guix/ui.scm (package->recutils): Add #:extra-fields and honor it.
---
 guix/ui.scm | 22 ++++++++++++++++------
 1 file changed, 16 insertions(+), 6 deletions(-)

diff --git a/guix/ui.scm b/guix/ui.scm
index 5060fd6..b8cfc65 100644
--- a/guix/ui.scm
+++ b/guix/ui.scm
@@ -946,9 +946,10 @@ followed by \"+ \", which makes for a valid multi-line 
field value in the
                       '()
                       str)))
 
-(define* (package->recutils p port #:optional (width (%text-width)))
+(define* (package->recutils p port #:optional (width (%text-width))
+                            #:key (extra-fields '()))
   "Write to PORT a `recutils' record of package P, arranging to fit within
-WIDTH columns."
+WIDTH columns.  EXTRA-FIELDS is a list of symbol/value pairs to emit."
   (define width*
     ;; The available number of columns once we've taken into account space for
     ;; the initial "+ " prefix.
@@ -993,11 +994,11 @@ WIDTH columns."
              (G_ "unknown"))))
   (format port "synopsis: ~a~%"
           (string-map (match-lambda
-                       (#\newline #\space)
-                       (chr       chr))
+                        (#\newline #\space)
+                        (chr       chr))
                       (or (and=> (package-synopsis-string p) P_)
                           "")))
-  (format port "~a~2%"
+  (format port "~a~%"
           (string->recutils
            (string-trim-right
             (parameterize ((%text-width width*))
@@ -1005,7 +1006,16 @@ WIDTH columns."
                (string-append "description: "
                               (or (and=> (package-description p) P_)
                                   ""))))
-            #\newline))))
+            #\newline)))
+  (for-each (match-lambda
+              ((field . value)
+               (let ((field (symbol->string field)))
+                 (format port "~a: ~a~%"
+                         field
+                         (fill-paragraph (object->string value) width*
+                                         (string-length field))))))
+            extra-fields)
+  (newline port))
 
 (define (string->generations str)
   "Return the list of generations matching a pattern in STR.  This function



reply via email to

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