guix-commits
[Top][All Lists]
Advanced

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

07/13: ui: Add procedures to display a profile generation.


From: Ludovic Courtès
Subject: 07/13: ui: Add procedures to display a profile generation.
Date: Mon, 26 Oct 2015 23:02:27 +0000

civodul pushed a commit to branch master
in repository guix.

commit ad18c7e64c844350f295a2f79605800a7718ed78
Author: Ludovic Courtès <address@hidden>
Date:   Mon Oct 26 21:16:20 2015 +0100

    ui: Add procedures to display a profile generation.
    
    * guix/scripts/package.scm (guix-package)[process-query](list-generations):
      Move part of the body to 'delete-generation' and
      'display-profile-content'.
    * guix/ui.scm (display-generation, display-profile-content): New
      procedures.
---
 guix/scripts/package.scm |   21 ++-------------------
 guix/ui.scm              |   28 ++++++++++++++++++++++++++++
 2 files changed, 30 insertions(+), 19 deletions(-)

diff --git a/guix/scripts/package.scm b/guix/scripts/package.scm
index ee45cdd..49df334 100644
--- a/guix/scripts/package.scm
+++ b/guix/scripts/package.scm
@@ -789,25 +789,8 @@ more information.~%"))
         (('list-generations pattern)
          (define (list-generation number)
            (unless (zero? number)
-             (let ((header (format #f (_ "Generation ~a\t~a") number
-                                   (date->string
-                                    (time-utc->date
-                                     (generation-time profile number))
-                                    "~b ~d ~Y ~T")))
-                   (current (generation-number profile)))
-               (if (= number current)
-                   (format #t (_ "~a\t(current)~%") header)
-                   (format #t "~a~%" header)))
-             (for-each (match-lambda
-                        (($ <manifest-entry> name version output location _)
-                         (format #t "  ~a\t~a\t~a\t~a~%"
-                                 name version output location)))
-
-                       ;; Show most recently installed packages last.
-                       (reverse
-                        (manifest-entries
-                         (profile-manifest
-                          (generation-file-name profile number)))))
+             (display-generation profile number)
+             (display-profile-content profile number)
              (newline)))
 
          (cond ((not (file-exists? profile)) ; XXX: race condition
diff --git a/guix/ui.scm b/guix/ui.scm
index 59ff2a7..c45c50f 100644
--- a/guix/ui.scm
+++ b/guix/ui.scm
@@ -85,6 +85,8 @@
             string->generations
             string->duration
             matching-generations
+            display-generation
+            display-profile-content
             run-guix-command
             run-guix
             program-name
@@ -1015,6 +1017,32 @@ DURATION-RELATION with the current time."
          filter-by-duration)
         (else #f)))
 
+(define (display-generation profile number)
+  "Display a one-line summary of generation NUMBER of PROFILE."
+  (unless (zero? number)
+    (let ((header (format #f (_ "Generation ~a\t~a") number
+                          (date->string
+                           (time-utc->date
+                            (generation-time profile number))
+                           "~b ~d ~Y ~T")))
+          (current (generation-number profile)))
+      (if (= number current)
+          (format #t (_ "~a\t(current)~%") header)
+          (format #t "~a~%" header)))))
+
+(define (display-profile-content profile number)
+  "Display the packages in PROFILE, generation NUMBER, in a human-readable
+way."
+  (for-each (match-lambda
+              (($ <manifest-entry> name version output location _)
+               (format #t "  ~a\t~a\t~a\t~a~%"
+                       name version output location)))
+
+            ;; Show most recently installed packages last.
+            (reverse
+             (manifest-entries
+              (profile-manifest (generation-file-name profile number))))))
+
 (define* (package-specification->name+version+output spec
                                                      #:optional (output "out"))
   "Parse package specification SPEC and return three value: the specified



reply via email to

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