~ruther/guix-local

20464dde13dc540951edc035d1af5d9fd756f2d1 — Ludovic Courtès 10 years ago ee2a7e3
guix build: Gracefully handle type errors in -e and -f.

* guix/scripts/build.scm (options->things-to-build)[validate-type]: New
procedure.
[ensure-list]: Use it.
1 files changed, 10 insertions(+), 4 deletions(-)

M guix/scripts/build.scm
M guix/scripts/build.scm => guix/scripts/build.scm +10 -4
@@ 404,10 404,16 @@ must be one of 'package', 'all', or 'transitive'~%")
(define (options->things-to-build opts)
  "Read the arguments from OPTS and return a list of high-level objects to
build---packages, gexps, derivations, and so on."
  (define ensure-list
    (match-lambda
      ((x ...) x)
      (x       (list x))))
  (define (validate-type x)
    (unless (or (package? x) (derivation? x) (gexp? x) (procedure? x))
      (leave (_ "~s: not something we can build~%") x)))

  (define (ensure-list x)
    (let ((lst (match x
                 ((x ...) x)
                 (x       (list x)))))
      (for-each validate-type lst)
      lst))

  (append-map (match-lambda
                (('argument . (? string? spec))