guix-commits
[Top][All Lists]
Advanced

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

08/10: weather: Accept package specs on the command line.


From: guix-commits
Subject: 08/10: weather: Accept package specs on the command line.
Date: Tue, 21 May 2019 18:09:55 -0400 (EDT)

civodul pushed a commit to branch master
in repository guix.

commit b1903b99e0c5c654dc152f16c79b5a933d6a9435
Author: Ludovic Courtès <address@hidden>
Date:   Tue May 21 22:58:19 2019 +0200

    weather: Accept package specs on the command line.
    
    Previously, non-option arguments would be ignored.  Now it puts them to
    good use.
    
    * guix/scripts/weather.scm (guix-weather)[package-list]: New procedure.
    Use it.
    * doc/guix.texi (Invoking guix weather): Adjust accordingly.
---
 doc/guix.texi            | 13 +++++++++++--
 guix/scripts/weather.scm | 21 ++++++++++++++++-----
 2 files changed, 27 insertions(+), 7 deletions(-)

diff --git a/doc/guix.texi b/doc/guix.texi
index 873eaba..f176bb0 100644
--- a/doc/guix.texi
+++ b/doc/guix.texi
@@ -10089,8 +10089,17 @@ challenge}, it ignores signatures on those 
substitutes, which is
 innocuous since the command only gathers statistics and cannot install
 those substitutes.
 
-Among other things, it is possible to query specific system types and
-specific package sets.  The available options are listed below.
+The general syntax is:
+
address@hidden
+guix weather @address@hidden address@hidden@dots{}]
address@hidden example
+
+When @var{packages} is omitted, @command{guix weather} checks the availability
+of substitutes for @emph{all} the packages, or for those specified with
address@hidden; otherwise it only considers the specified packages.  It
+is also possible to query specific system types with @option{--system}.  The
+available options are listed below.
 
 @table @code
 @item address@hidden
diff --git a/guix/scripts/weather.scm b/guix/scripts/weather.scm
index 4b12f95..78b8674 100644
--- a/guix/scripts/weather.scm
+++ b/guix/scripts/weather.scm
@@ -252,7 +252,7 @@ are queued~%")
 ;;;
 
 (define (show-help)
-  (display (G_ "Usage: guix weather [OPTIONS]
+  (display (G_ "Usage: guix weather [OPTIONS] [PACKAGES ...]
 Report the availability of substitutes.\n"))
   (display (G_ "
       --substitute-urls=URLS
@@ -469,6 +469,20 @@ SERVER.  Display information for packages with at least 
THRESHOLD dependents."
 ;;;
 
 (define (guix-weather . args)
+  (define (package-list opts)
+    ;; Return the package list specified by OPTS.
+    (let ((file (assoc-ref opts 'manifest))
+          (base (filter-map (match-lambda
+                              (('argument . spec)
+                               (specification->package spec))
+                              (_
+                               #f))
+                            opts)))
+      (if (and (not file) (null? base))
+          (all-packages)
+          (append base
+                  (if file (load-manifest file) '())))))
+
   (with-error-handling
     (parameterize ((current-terminal-columns (terminal-columns)))
       (let* ((opts     (parse-command-line args %options
@@ -481,10 +495,7 @@ SERVER.  Display information for packages with at least 
THRESHOLD dependents."
                                           opts)
                          (() (list (%current-system)))
                          (systems systems)))
-             (packages (let ((file (assoc-ref opts 'manifest)))
-                         (if file
-                             (load-manifest file)
-                             (all-packages))))
+             (packages (package-list opts))
              (items    (with-store store
                          (parameterize ((%graft? #f))
                            (concatenate



reply via email to

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