1 ;;; GNU Guix --- Functional package management for GNU
2 ;;; Copyright © 2015 Federico Beffa <beffa@fbengineering.ch>
4 ;;; This file is part of GNU Guix.
6 ;;; GNU Guix is free software; you can redistribute it and/or modify it
7 ;;; under the terms of the GNU General Public License as published by
8 ;;; the Free Software Foundation; either version 3 of the License, or (at
9 ;;; your option) any later version.
11 ;;; GNU Guix is distributed in the hope that it will be useful, but
12 ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
13 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 ;;; GNU General Public License for more details.
16 ;;; You should have received a copy of the GNU General Public License
17 ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
19 (define-module (guix scripts import elpa)
20 #:use-module (guix ui)
21 #:use-module (guix utils)
22 #:use-module (guix scripts)
23 #:use-module (guix import elpa)
24 #:use-module (guix scripts import)
25 #:use-module (srfi srfi-1)
26 #:use-module (srfi srfi-11)
27 #:use-module (srfi srfi-37)
28 #:use-module (ice-9 match)
29 #:use-module (ice-9 format)
30 #:export (guix-import-elpa))
34 ;;; Command-line options.
37 (define %default-options
41 (display (G_ "Usage: guix import elpa PACKAGE-NAME
42 Import the latest package named PACKAGE-NAME from an ELPA repository.\n"))
44 -a, --archive=ARCHIVE specify the archive repository"))
46 -h, --help display this help and exit"))
48 -V, --version display version information and exit"))
50 (show-bug-report-information))
53 ;; Specification of the command-line options.
54 (cons* (option '(#\h "help") #f #f
58 (option '(#\V "version") #f #f
60 (show-version-and-exit "guix import elpa")))
61 (option '(#\a "archive") #t #f
62 (lambda (opt name arg result)
63 (alist-cons 'repo (string->symbol arg)
64 (alist-delete 'repo result))))
65 %standard-import-options))
72 (define (guix-import-elpa . args)
73 (define (parse-options)
74 ;; Return the alist of option values.
75 (args-fold* args %options
76 (lambda (opt name arg result)
77 (leave (G_ "~A: unrecognized option~%") name))
79 (alist-cons 'argument arg result))
82 (let* ((opts (parse-options))
83 (args (filter-map (match-lambda
90 (let ((sexp (elpa->guix-package package-name (assoc-ref opts 'repo))))
92 (leave (G_ "failed to download package '~a'~%") package-name))
95 (leave (G_ "too few arguments~%")))
97 (leave (G_ "too many arguments~%"))))))
99 ;;; elpa.scm ends here