unofficial mirror of guix-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Cyril Roelandt <tipecaml@gmail.com>
To: guix-devel@gnu.org
Subject: [PATCH v2 2/2] guix package: add a "show" option.
Date: Thu, 17 Jul 2014 02:54:10 +0200	[thread overview]
Message-ID: <1405558450-13602-2-git-send-email-tipecaml@gmail.com> (raw)
In-Reply-To: <1405558450-13602-1-git-send-email-tipecaml@gmail.com>

* doc/guix.texi: Update the documentation.
* guix/scripts/package.scm: Add a "show" option.
* tests/guix-package.sh: Add a test for the "show" option.
---
 doc/guix.texi            | 23 +++++++++++++++++++++++
 guix/scripts/package.scm | 15 +++++++++++++++
 tests/guix-package.sh    |  3 +++
 3 files changed, 41 insertions(+)

diff --git a/doc/guix.texi b/doc/guix.texi
index 7ea40e5..38aade5 100644
--- a/doc/guix.texi
+++ b/doc/guix.texi
@@ -839,6 +839,29 @@ name: gmp
 @dots{}
 @end example
 
+@item --show=@var{package}
+Show details about a given package in @code{recutils} format (@pxref{Top, GNU
+recutils databases,, recutils, GNU recutils manual}).
+
+@example
+$ guix package --show=python | recsel -p name,version
+name: python
+version: 2.7.6
+
+name: python
+version: 3.3.5
+@end example
+
+You may also specify the full name of a package to only get details about a
+specific version of it:
+@example
+$ guix package --show=python-3.3.5 | recsel -p name,version
+name: python
+version: 3.3.5
+@end example
+
+
+
 @item --list-installed[=@var{regexp}]
 @itemx -I [@var{regexp}]
 List the currently installed packages in the specified profile, with the
diff --git a/guix/scripts/package.scm b/guix/scripts/package.scm
index 1c3209f..0d17414 100644
--- a/guix/scripts/package.scm
+++ b/guix/scripts/package.scm
@@ -517,6 +517,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 +617,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 ,arg)
+                                 result)
+                           #f)))
 
          %standard-build-options))
 
@@ -1042,6 +1049,14 @@ more information.~%"))
                       (find-packages-by-description regexp)))
            #t))
 
+        (('show requested-name)
+         (let-values (((name version)
+                       (package-name->name+version requested-name)))
+           (leave-on-EPIPE
+            (for-each (cute package->recutils <> (current-output-port))
+                      (find-packages-by-name name version)))
+           #t))
+
         (('search-paths)
          (let* ((manifest (profile-manifest profile))
                 (entries  (manifest-entries manifest))
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-17  1:03 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-07-13 18:54 [PATCH] guix package: add a "show" option Cyril Roelandt
2014-07-13 21:32 ` 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     ` Cyril Roelandt [this message]
2014-07-17 23:30       ` [PATCH v2 2/2] guix package: add a "show" option 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

  List information: https://guix.gnu.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1405558450-13602-2-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 public inbox

	https://git.savannah.gnu.org/cgit/guix.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).