all messages for Guix-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Cyril Roelandt <tipecaml@gmail.com>
To: guix-devel@gnu.org
Subject: [PATCH] guix package: add a "show" option.
Date: Sun, 13 Jul 2014 20:54:01 +0200	[thread overview]
Message-ID: <1405277641-2891-1-git-send-email-tipecaml@gmail.com> (raw)

* guix/packages.scm (package-direct-inputs): New procedure.
* guix/scripts/package.scm: Add a "show" option.
* tests/guix-package.sh: Add a test for the "show" option.
---
 guix/packages.scm        |  8 ++++++++
 guix/scripts/package.scm | 37 +++++++++++++++++++++++++++++++++++++
 tests/guix-package.sh    |  3 +++
 3 files changed, 48 insertions(+)

diff --git a/guix/packages.scm b/guix/packages.scm
index 985a573..4fda77f 100644
--- a/guix/packages.scm
+++ b/guix/packages.scm
@@ -75,6 +75,7 @@
             package-location
             package-field-location
 
+            package-direct-inputs
             package-transitive-inputs
             package-transitive-target-inputs
             package-transitive-native-inputs
@@ -467,6 +468,13 @@ IMPORTED-MODULES specify modules to use/import for use by SNIPPET."
     ((? string? file)
      (add-to-store store (basename file) #t "sha256" file))))
 
+(define (package-direct-inputs package)
+  (sort (append (package-inputs package)
+                (package-native-inputs package)
+                (package-propagated-inputs package))
+        (lambda (p1 p2)
+          (string<? (car p1) (car p2)))))
+
 (define (transitive-inputs inputs)
   (let loop ((inputs  inputs)
              (result '()))
diff --git a/guix/scripts/package.scm b/guix/scripts/package.scm
index 1c3209f..2b5efc9 100644
--- a/guix/scripts/package.scm
+++ b/guix/scripts/package.scm
@@ -22,6 +22,7 @@
   #:use-module (guix ui)
   #:use-module (guix store)
   #:use-module (guix derivations)
+  #:use-module (guix licenses)
   #:use-module (guix packages)
   #:use-module (guix profiles)
   #:use-module (guix utils)
@@ -517,6 +518,8 @@ Install, remove, or upgrade PACKAGES in a single transaction.\n"))
   (display (_ "
   -A, --list-available[=REGEXP]
                          list available packages matching REGEXP"))
+  (display (_ "
+  --show=PACKAGE         show details about PACKAGE"))
   (newline)
   (show-build-options-help)
   (newline)
@@ -615,6 +618,11 @@ Install, remove, or upgrade PACKAGES in a single transaction.\n"))
                    (values (cons `(query list-available ,(or arg ""))
                                  result)
                            #f)))
+         (option '("show") #t #t
+                 (lambda (opt name arg result arg-handler)
+                   (values (cons `(query show-package ,arg)
+                                 result)
+                           #f)))
 
          %standard-build-options))
 
@@ -1011,6 +1019,35 @@ more information.~%"))
                       (reverse installed)))
            #t))
 
+        (('show-package requested-name)
+         (let* ((available (fold-packages
+                            (lambda (p r)
+                              (let ((name (package-name p))
+                                    (full-name (package-full-name p)))
+                                (if (or (string=? requested-name name)
+                                        (string=? requested-name full-name))
+                                    (cons p r)
+                                    r)))
+                            '())))
+           (leave-on-EPIPE
+            (for-each (lambda (p)
+                        (format #t "Package: ~a\n\
+Version: ~a\n\
+Description: ~a\n\
+Depends: ~a\n\
+Homepage: ~a\n\
+License: ~a\n~%"
+                                (package-name p)
+                                (package-version p)
+                                (package-description p)
+                                (string-join (map car (package-direct-inputs p)) ", ")
+                                (package-home-page p)
+                                (license-name (package-license p))))
+                      (sort available
+                            (lambda (p1 p2)
+                              (version>? (package-version p2) (package-version p1))))))
+           #t))
+
         (('list-available regexp)
          (let* ((regexp    (and regexp (make-regexp regexp)))
                 (available (fold-packages
diff --git a/tests/guix-package.sh b/tests/guix-package.sh
index 4d75955..d388514 100644
--- a/tests/guix-package.sh
+++ b/tests/guix-package.sh
@@ -176,6 +176,9 @@ then false; else true; fi
 # Check whether `--list-available' returns something sensible.
 guix package -p "$profile" -A 'gui.*e' | grep guile
 
+# Check whether `--show' returns something sensible.
+guix package -p "$profile" --show=guile | grep "^Package: guile"
+
 # There's no generation older than 12 months, so the following command should
 # have no effect.
 generation="`readlink_base "$profile"`"
-- 
1.8.4.rc3

             reply	other threads:[~2014-07-13 19:03 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-07-13 18:54 Cyril Roelandt [this message]
2014-07-13 21:32 ` [PATCH] guix package: add a "show" option Ludovic Courtès
2014-07-14  8:41   ` Andreas Enge
2014-07-14  8:47     ` Alex Sassmannshausen
2014-07-14  9:03       ` John Darrington
2014-07-15 21:23 ` Ludovic Courtès
2014-07-17  0:54   ` [PATCH v2 1/2] guix ui: add the "depends" field to package->recutils: Cyril Roelandt
2014-07-17  0:54     ` [PATCH v2 2/2] guix package: add a "show" option Cyril Roelandt
2014-07-17 23:30       ` Ludovic Courtès
2014-07-17 23:26     ` [PATCH v2 1/2] guix ui: add the "depends" field to package->recutils: Ludovic Courtès
2014-07-20 23:48       ` [PATCH v3 " Cyril Roelandt
2014-07-21 15:51         ` Ludovic Courtès
2014-07-20 23:49       ` [PATCH v2 " Cyril Roelandt
2014-07-21 15:53         ` Ludovic Courtès

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=1405277641-2891-1-git-send-email-tipecaml@gmail.com \
    --to=tipecaml@gmail.com \
    --cc=guix-devel@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.