all messages for Guix-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Oleg Pykhalov <go.wigust@gmail.com>
To: 33448@debbugs.gnu.org
Subject: [bug#33448] [PATCH 1/3] describe: Use a procedure to format output.
Date: Wed, 21 Nov 2018 17:17:13 +0300	[thread overview]
Message-ID: <20181121141715.16417-1-go.wigust@gmail.com> (raw)
In-Reply-To: <20181120222616.3941-1-go.wigust@gmail.com>

* 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
+    (($ <channel> name url branch commit location)
+     `(channel
+       (name ,name)
+       (url ,url)
+       (commit ,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 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))
 
 \f
-- 
2.19.1

  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 ` Oleg Pykhalov [this message]
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   ` [bug#33448] [PATCH 3/3] describe: Add recutils format Oleg Pykhalov
2018-11-21 21:34     ` 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-1-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.