guix-commits
[Top][All Lists]
Advanced

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

01/01: graph: Add '--expression'.


From: Ludovic Courtès
Subject: 01/01: graph: Add '--expression'.
Date: Wed, 02 Sep 2015 21:44:34 +0000

civodul pushed a commit to branch master
in repository guix.

commit 4c8f997a7d6f4c9d7eae73804e9784b4562eb213
Author: Ludovic Courtès <address@hidden>
Date:   Wed Sep 2 15:23:52 2015 +0200

    graph: Add '--expression'.
    
    * guix/scripts/graph.scm (%options, show-help): Add '--expression'.
      (guix-graph): Call 'read/eval-package-expression' for 'expression'
      pairs in OPTS.
    * tests/guix-graph.sh: Add tests.
    * doc/guix.texi (Invoking guix graph): Document it.
---
 doc/guix.texi          |   10 ++++++++++
 guix/scripts/graph.scm |   17 ++++++++++++-----
 tests/guix-graph.sh    |    5 +++++
 3 files changed, 27 insertions(+), 5 deletions(-)

diff --git a/doc/guix.texi b/doc/guix.texi
index 6defb0b..f943540 100644
--- a/doc/guix.texi
+++ b/doc/guix.texi
@@ -4417,6 +4417,16 @@ the values listed above.
 
 @item --list-types
 List the supported graph types.
+
address@hidden address@hidden
address@hidden -e @var{expr}
+Consider the package @var{expr} evaluates to.
+
+This is useful to precisely refer to a package, as in this example:
+
address@hidden
+guix graph -e '(@@@@ (gnu packages commencement) gnu-make-final)'
address@hidden example
 @end table
 
 
diff --git a/guix/scripts/graph.scm b/guix/scripts/graph.scm
index 1719ffc..2b671be 100644
--- a/guix/scripts/graph.scm
+++ b/guix/scripts/graph.scm
@@ -380,6 +380,9 @@ given BACKEND.  Use NODE-TYPE to traverse the DAG."
                 (lambda (opt name arg result)
                   (list-node-types)
                   (exit 0)))
+        (option '(#\e "expression") #t #f
+                (lambda (opt name arg result)
+                  (alist-cons 'expression arg result)))
         (option '(#\h "help") #f #f
                 (lambda args
                   (show-help)
@@ -397,6 +400,8 @@ Emit a Graphviz (dot) representation of the dependencies of 
PACKAGE...\n"))
   -t, --type=TYPE        represent nodes of the given TYPE"))
   (display (_ "
       --list-types       list the available graph types"))
+  (display (_ "
+  -e, --expression=EXPR  consider the package EXPR evaluates to"))
   (newline)
   (display (_ "
   -h, --help             display this help and exit"))
@@ -417,12 +422,14 @@ Emit a Graphviz (dot) representation of the dependencies 
of PACKAGE...\n"))
   (with-error-handling
     (let* ((opts     (parse-command-line args %options
                                          (list %default-options)))
-           (specs    (filter-map (match-lambda
-                                   (('argument . spec) spec)
-                                   (_ #f))
-                                 opts))
            (type     (assoc-ref opts 'node-type))
-           (packages (map specification->package specs)))
+           (packages (filter-map (match-lambda
+                                   (('argument . spec)
+                                    (specification->package spec))
+                                   (('expression . exp)
+                                    (read/eval-package-expression exp))
+                                   (_ #f))
+                                 opts)))
       (with-store store
         (run-with-store store
           (mlet %store-monad ((nodes (mapm %store-monad
diff --git a/tests/guix-graph.sh b/tests/guix-graph.sh
index 199258a..e0cbebb 100644
--- a/tests/guix-graph.sh
+++ b/tests/guix-graph.sh
@@ -32,3 +32,8 @@ done
 
 guix build guile-bootstrap
 guix graph -t references guile-bootstrap | grep guile-bootstrap
+
+guix graph -e '(@ (gnu packages bootstrap) %bootstrap-guile)' \
+    | grep guile-bootstrap
+
+if guix graph -e +; then false; else true; fi



reply via email to

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