import: Use PARSE-COMMAND-LINE for options.

* guix/scripts/import/go.scm (guix-import-go)[parse-options]: Use
PARSE-COMMAND-LINE instead of ARGS-FOLD*.
* guix/scripts/import/egg.scm (guix-import-egg)[parse-options]:
Likewise.
* guix/scripts/import/gem.scm (guix-import-gem)[parse-options]:
Likewise.
* guix/scripts/import/gnu.scm (guix-import-gnu)[parse-options]:
Likewise.
* guix/scripts/import/cpan.scm (guix-import-cpan)[parse-options]:
Likewise.
* guix/scripts/import/cran.scm (guix-import-cran)[parse-options]:
Likewise.
* guix/scripts/import/elpa.scm (guix-import-elpa)[parse-options]:
Likewise.
* guix/scripts/import/json.scm (guix-import-json)[parse-options]:
Likewise.
* guix/scripts/import/opam.scm (guix-import-opam)[parse-options]:
Likewise.
* guix/scripts/import/pypi.scm (guix-import-pypi)[parse-options]:
Likewise.
* guix/scripts/import/crate.scm (guix-import-crate)[parse-options]:
Likewise.
* guix/scripts/import/texlive.scm (guix-import-texlive)[parse-options]:
Likewise.
* guix/scripts/import/hackage.scm (guix-import-hackage)[parse-options]:
Likewise.
* guix/scripts/import/stackage.scm (guix-import-stackage)[parse-options]:
Likewise.

Signed-off-by: Ludovic Courtès <ludo@gnu.org>
This commit is contained in:
Sarah Morgensen 2021-08-03 11:24:50 -07:00 committed by Ludovic Courtès
parent f44fe1d5bf
commit 15452f319c
No known key found for this signature in database
GPG Key ID: 090B11993D9AEBB5
14 changed files with 42 additions and 85 deletions

@ -1,5 +1,6 @@
;;; GNU Guix --- Functional package management for GNU ;;; GNU Guix --- Functional package management for GNU
;;; Copyright © 2014 Eric Bavier <bavier@member.fsf.org> ;;; Copyright © 2014 Eric Bavier <bavier@member.fsf.org>
;;; Copyright © 2021 Sarah Morgensen <iskarian@mgsn.dev>
;;; ;;;
;;; This file is part of GNU Guix. ;;; This file is part of GNU Guix.
;;; ;;;
@ -66,12 +67,8 @@ Import and convert the CPAN package for PACKAGE-NAME.\n"))
(define (guix-import-cpan . args) (define (guix-import-cpan . args)
(define (parse-options) (define (parse-options)
;; Return the alist of option values. ;; Return the alist of option values.
(args-fold* args %options (parse-command-line args %options (list %default-options)
(lambda (opt name arg result) #:build-options? #f))
(leave (G_ "~A: unrecognized option~%") name))
(lambda (arg result)
(alist-cons 'argument arg result))
%default-options))
(let* ((opts (parse-options)) (let* ((opts (parse-options))
(args (filter-map (match-lambda (args (filter-map (match-lambda

@ -2,6 +2,7 @@
;;; Copyright © 2014 Eric Bavier <bavier@member.fsf.org> ;;; Copyright © 2014 Eric Bavier <bavier@member.fsf.org>
;;; Copyright © 2015, 2017, 2019, 2020 Ricardo Wurmus <rekado@elephly.net> ;;; Copyright © 2015, 2017, 2019, 2020 Ricardo Wurmus <rekado@elephly.net>
;;; Copyright © 2020 Martin Becze <mjbecze@riseup.net> ;;; Copyright © 2020 Martin Becze <mjbecze@riseup.net>
;;; Copyright © 2021 Sarah Morgensen <iskarian@mgsn.dev>
;;; ;;;
;;; This file is part of GNU Guix. ;;; This file is part of GNU Guix.
;;; ;;;
@ -86,12 +87,8 @@ Import and convert the CRAN package for PACKAGE-NAME.\n"))
(define (guix-import-cran . args) (define (guix-import-cran . args)
(define (parse-options) (define (parse-options)
;; Return the alist of option values. ;; Return the alist of option values.
(args-fold* args %options (parse-command-line args %options (list %default-options)
(lambda (opt name arg result) #:build-options? #f))
(leave (G_ "~A: unrecognized option~%") name))
(lambda (arg result)
(alist-cons 'argument arg result))
%default-options))
(let* ((opts (parse-options)) (let* ((opts (parse-options))
(args (filter-map (match-lambda (args (filter-map (match-lambda

@ -3,6 +3,7 @@
;;; Copyright © 2014 David Thompson <davet@gnu.org> ;;; Copyright © 2014 David Thompson <davet@gnu.org>
;;; Copyright © 2016 David Craven <david@craven.ch> ;;; Copyright © 2016 David Craven <david@craven.ch>
;;; Copyright © 2019, 2020 Martin Becze <mjbecze@riseup.net> ;;; Copyright © 2019, 2020 Martin Becze <mjbecze@riseup.net>
;;; Copyright © 2021 Sarah Morgensen <iskarian@mgsn.dev>
;;; ;;;
;;; This file is part of GNU Guix. ;;; This file is part of GNU Guix.
;;; ;;;
@ -75,13 +76,8 @@ Import and convert the crates.io package for PACKAGE-NAME.\n"))
(define (guix-import-crate . args) (define (guix-import-crate . args)
(define (parse-options) (define (parse-options)
;; Return the alist of option values. ;; Return the alist of option values.
(args-fold* args %options (parse-command-line args %options (list %default-options)
(lambda (opt name arg result) #:build-options? #f))
(leave (G_ "~A: unrecognized option~%") name))
(lambda (arg result)
(alist-cons 'argument arg result))
%default-options))
(let* ((opts (parse-options)) (let* ((opts (parse-options))
(args (filter-map (match-lambda (args (filter-map (match-lambda

@ -1,5 +1,6 @@
;;; GNU Guix --- Functional package management for GNU ;;; GNU Guix --- Functional package management for GNU
;;; Copyright © 2021 Xinglu Chen <public@yoctocell.xyz> ;;; Copyright © 2021 Xinglu Chen <public@yoctocell.xyz>
;;; Copyright © 2021 Sarah Morgensen <iskarian@mgsn.dev>
;;; ;;;
;;; This file is part of GNU Guix. ;;; This file is part of GNU Guix.
;;; ;;;
@ -71,12 +72,8 @@ Import and convert the egg package for PACKAGE-NAME.\n"))
(define (guix-import-egg . args) (define (guix-import-egg . args)
(define (parse-options) (define (parse-options)
;; Return the alist of option values. ;; Return the alist of option values.
(args-fold* args %options (parse-command-line args %options (list %default-options)
(lambda (opt name arg result) #:build-options? #f))
(leave (G_ "~A: unrecognized option~%") name))
(lambda (arg result)
(alist-cons 'argument arg result))
%default-options))
(let* ((opts (parse-options)) (let* ((opts (parse-options))
(repo (and=> (assoc-ref opts 'repo) string->symbol)) (repo (and=> (assoc-ref opts 'repo) string->symbol))

@ -2,6 +2,7 @@
;;; Copyright © 2015 Federico Beffa <beffa@fbengineering.ch> ;;; Copyright © 2015 Federico Beffa <beffa@fbengineering.ch>
;;; Copyright © 2018 Oleg Pykhalov <go.wigust@gmail.com> ;;; Copyright © 2018 Oleg Pykhalov <go.wigust@gmail.com>
;;; Copyright © 2020 Martin Becze <mjbecze@riseup.net> ;;; Copyright © 2020 Martin Becze <mjbecze@riseup.net>
;;; Copyright © 2021 Sarah Morgensen <iskarian@mgsn.dev>
;;; ;;;
;;; This file is part of GNU Guix. ;;; This file is part of GNU Guix.
;;; ;;;
@ -80,12 +81,8 @@ Import the latest package named PACKAGE-NAME from an ELPA repository.\n"))
(define (guix-import-elpa . args) (define (guix-import-elpa . args)
(define (parse-options) (define (parse-options)
;; Return the alist of option values. ;; Return the alist of option values.
(args-fold* args %options (parse-command-line args %options (list %default-options)
(lambda (opt name arg result) #:build-options? #f))
(leave (G_ "~A: unrecognized option~%") name))
(lambda (arg result)
(alist-cons 'argument arg result))
%default-options))
(let* ((opts (parse-options)) (let* ((opts (parse-options))
(args (filter-map (match-lambda (args (filter-map (match-lambda

@ -1,6 +1,7 @@
;;; GNU Guix --- Functional package management for GNU ;;; GNU Guix --- Functional package management for GNU
;;; Copyright © 2015 David Thompson <davet@gnu.org> ;;; Copyright © 2015 David Thompson <davet@gnu.org>
;;; Copyright © 2018 Oleg Pykhalov <go.wigust@gmail.com> ;;; Copyright © 2018 Oleg Pykhalov <go.wigust@gmail.com>
;;; Copyright © 2021 Sarah Morgensen <iskarian@mgsn.dev>
;;; ;;;
;;; This file is part of GNU Guix. ;;; This file is part of GNU Guix.
;;; ;;;
@ -73,12 +74,8 @@ Import and convert the RubyGems package for PACKAGE-NAME.\n"))
(define (guix-import-gem . args) (define (guix-import-gem . args)
(define (parse-options) (define (parse-options)
;; Return the alist of option values. ;; Return the alist of option values.
(args-fold* args %options (parse-command-line args %options (list %default-options)
(lambda (opt name arg result) #:build-options? #f))
(leave (G_ "~A: unrecognized option~%") name))
(lambda (arg result)
(alist-cons 'argument arg result))
%default-options))
(let* ((opts (parse-options)) (let* ((opts (parse-options))
(args (filter-map (match-lambda (args (filter-map (match-lambda

@ -1,5 +1,6 @@
;;; GNU Guix --- Functional package management for GNU ;;; GNU Guix --- Functional package management for GNU
;;; Copyright © 2014, 2016 Ludovic Courtès <ludo@gnu.org> ;;; Copyright © 2014, 2016 Ludovic Courtès <ludo@gnu.org>
;;; Copyright © 2021 Sarah Morgensen <iskarian@mgsn.dev>
;;; ;;;
;;; This file is part of GNU Guix. ;;; This file is part of GNU Guix.
;;; ;;;
@ -81,12 +82,8 @@ Return a package declaration template for PACKAGE, a GNU package.\n"))
(define (guix-import-gnu . args) (define (guix-import-gnu . args)
(define (parse-options) (define (parse-options)
;; Return the alist of option values. ;; Return the alist of option values.
(args-fold* args %options (parse-command-line args %options (list %default-options)
(lambda (opt name arg result) #:build-options? #f))
(leave (G_ "~A: unrecognized option~%") name))
(lambda (arg result)
(alist-cons 'argument arg result))
%default-options))
(let* ((opts (parse-options)) (let* ((opts (parse-options))
(args (filter-map (match-lambda (args (filter-map (match-lambda

@ -2,6 +2,7 @@
;;; Copyright © 2020 Katherine Cox-Buday <cox.katherine.e@gmail.com> ;;; Copyright © 2020 Katherine Cox-Buday <cox.katherine.e@gmail.com>
;;; Copyright © 2021 Maxim Cournoyer <maxim.cournoyer@gmail.com> ;;; Copyright © 2021 Maxim Cournoyer <maxim.cournoyer@gmail.com>
;;; Copyright © 2021 Zheng Junjie <873216071@qq.com> ;;; Copyright © 2021 Zheng Junjie <873216071@qq.com>
;;; Copyright © 2021 Sarah Morgensen <iskarian@mgsn.dev>
;;; ;;;
;;; This file is part of GNU Guix. ;;; This file is part of GNU Guix.
;;; ;;;
@ -83,12 +84,8 @@ that are not yet in Guix"))
(define (guix-import-go . args) (define (guix-import-go . args)
(define (parse-options) (define (parse-options)
;; Return the alist of option values. ;; Return the alist of option values.
(args-fold* args %options (parse-command-line args %options (list %default-options)
(lambda (opt name arg result) #:build-options? #f))
(leave (G_ "~A: unrecognized option~%") name))
(lambda (arg result)
(alist-cons 'argument arg result))
%default-options))
(let* ((opts (parse-options)) (let* ((opts (parse-options))
(args (filter-map (match-lambda (args (filter-map (match-lambda

@ -1,6 +1,7 @@
;;; GNU Guix --- Functional package management for GNU ;;; GNU Guix --- Functional package management for GNU
;;; Copyright © 2015 Federico Beffa <beffa@fbengineering.ch> ;;; Copyright © 2015 Federico Beffa <beffa@fbengineering.ch>
;;; Copyright © 2018 Ricardo Wurmus <rekado@elephly.net> ;;; Copyright © 2018 Ricardo Wurmus <rekado@elephly.net>
;;; Copyright © 2021 Sarah Morgensen <iskarian@mgsn.dev>
;;; ;;;
;;; This file is part of GNU Guix. ;;; This file is part of GNU Guix.
;;; ;;;
@ -105,12 +106,8 @@ version.\n"))
(define (guix-import-hackage . args) (define (guix-import-hackage . args)
(define (parse-options) (define (parse-options)
;; Return the alist of option values. ;; Return the alist of option values.
(args-fold* args %options (parse-command-line args %options (list %default-options)
(lambda (opt name arg result) #:build-options? #f))
(leave (G_ "~A: unrecognized option~%") name))
(lambda (arg result)
(alist-cons 'argument arg result))
%default-options))
(define (run-importer package-name opts error-fn) (define (run-importer package-name opts error-fn)
(let* ((arguments (list (let* ((arguments (list

@ -2,6 +2,7 @@
;;; Copyright © 2014 Eric Bavier <bavier@member.fsf.org> ;;; Copyright © 2014 Eric Bavier <bavier@member.fsf.org>
;;; Copyright © 2015, 2017 Ricardo Wurmus <rekado@elephly.net> ;;; Copyright © 2015, 2017 Ricardo Wurmus <rekado@elephly.net>
;;; Copyright © 2021 Simon Tournier <zimon.toutoune@gmail.com> ;;; Copyright © 2021 Simon Tournier <zimon.toutoune@gmail.com>
;;; Copyright © 2021 Sarah Morgensen <iskarian@mgsn.dev>
;;; ;;;
;;; This file is part of GNU Guix. ;;; This file is part of GNU Guix.
;;; ;;;
@ -74,12 +75,8 @@ Import and convert the JSON package definition in PACKAGE-FILE.\n"))
(define (guix-import-json . args) (define (guix-import-json . args)
(define (parse-options) (define (parse-options)
;; Return the alist of option values. ;; Return the alist of option values.
(args-fold* args %options (parse-command-line args %options (list %default-options)
(lambda (opt name arg result) #:build-options? #f))
(leave (G_ "~A: unrecognized option~%") name))
(lambda (arg result)
(alist-cons 'argument arg result))
%default-options))
(let* ((opts (parse-options)) (let* ((opts (parse-options))
(args (filter-map (match-lambda (args (filter-map (match-lambda

@ -1,5 +1,6 @@
;;; GNU Guix --- Functional package management for GNU ;;; GNU Guix --- Functional package management for GNU
;;; Copyright © 2018 Julien Lepiller <julien@lepiller.eu> ;;; Copyright © 2018 Julien Lepiller <julien@lepiller.eu>
;;; Copyright © 2021 Sarah Morgensen <iskarian@mgsn.dev>
;;; ;;;
;;; This file is part of GNU Guix. ;;; This file is part of GNU Guix.
;;; ;;;
@ -76,12 +77,8 @@ Import and convert the opam package for PACKAGE-NAME.\n"))
(define (guix-import-opam . args) (define (guix-import-opam . args)
(define (parse-options) (define (parse-options)
;; Return the alist of option values. ;; Return the alist of option values.
(args-fold* args %options (parse-command-line args %options (list %default-options)
(lambda (opt name arg result) #:build-options? #f))
(leave (G_ "~A: unrecognized option~%") name))
(lambda (arg result)
(alist-cons 'argument arg result))
%default-options))
(let* ((opts (parse-options)) (let* ((opts (parse-options))
(repo (and=> (assoc-ref opts 'repo) string->symbol)) (repo (and=> (assoc-ref opts 'repo) string->symbol))

@ -1,6 +1,7 @@
;;; GNU Guix --- Functional package management for GNU ;;; GNU Guix --- Functional package management for GNU
;;; Copyright © 2014 David Thompson <davet@gnu.org> ;;; Copyright © 2014 David Thompson <davet@gnu.org>
;;; Copyright © 2018 Ricardo Wurmus <rekado@elephly.net> ;;; Copyright © 2018 Ricardo Wurmus <rekado@elephly.net>
;;; Copyright © 2021 Sarah Morgensen <iskarian@mgsn.dev>
;;; ;;;
;;; This file is part of GNU Guix. ;;; This file is part of GNU Guix.
;;; ;;;
@ -72,12 +73,8 @@ Import and convert the PyPI package for PACKAGE-NAME.\n"))
(define (guix-import-pypi . args) (define (guix-import-pypi . args)
(define (parse-options) (define (parse-options)
;; Return the alist of option values. ;; Return the alist of option values.
(args-fold* args %options (parse-command-line args %options (list %default-options)
(lambda (opt name arg result) #:build-options? #f))
(leave (G_ "~A: unrecognized option~%") name))
(lambda (arg result)
(alist-cons 'argument arg result))
%default-options))
(let* ((opts (parse-options)) (let* ((opts (parse-options))
(args (filter-map (match-lambda (args (filter-map (match-lambda

@ -1,6 +1,7 @@
;;; GNU Guix --- Functional package management for GNU ;;; GNU Guix --- Functional package management for GNU
;;; Copyright © 2017 Federico Beffa <beffa@fbengineering.ch> ;;; Copyright © 2017 Federico Beffa <beffa@fbengineering.ch>
;;; Copyright © 2018 Ricardo Wurmus <rekado@elephly.net> ;;; Copyright © 2018 Ricardo Wurmus <rekado@elephly.net>
;;; Copyright © 2021 Sarah Morgensen <iskarian@mgsn.dev>
;;; ;;;
;;; This file is part of GNU Guix. ;;; This file is part of GNU Guix.
;;; ;;;
@ -89,12 +90,8 @@ Import and convert the LTS Stackage package for PACKAGE-NAME.\n"))
(define (guix-import-stackage . args) (define (guix-import-stackage . args)
(define (parse-options) (define (parse-options)
;; Return the alist of option values. ;; Return the alist of option values.
(args-fold* args %options (parse-command-line args %options (list %default-options)
(lambda (opt name arg result) #:build-options? #f))
(leave (G_ "~A: unrecognized option~%") name))
(lambda (arg result)
(alist-cons 'argument arg result))
%default-options))
(define (run-importer package-name opts error-fn) (define (run-importer package-name opts error-fn)
(let* ((arguments (list (let* ((arguments (list

@ -1,5 +1,6 @@
;;; GNU Guix --- Functional package management for GNU ;;; GNU Guix --- Functional package management for GNU
;;; Copyright © 2017 Ricardo Wurmus <rekado@elephly.net> ;;; Copyright © 2017 Ricardo Wurmus <rekado@elephly.net>
;;; Copyright © 2021 Sarah Morgensen <iskarian@mgsn.dev>
;;; ;;;
;;; This file is part of GNU Guix. ;;; This file is part of GNU Guix.
;;; ;;;
@ -73,12 +74,8 @@ Import and convert the Texlive package for PACKAGE-NAME.\n"))
(define (guix-import-texlive . args) (define (guix-import-texlive . args)
(define (parse-options) (define (parse-options)
;; Return the alist of option values. ;; Return the alist of option values.
(args-fold* args %options (parse-command-line args %options (list %default-options)
(lambda (opt name arg result) #:build-options? #f))
(leave (G_ "~A: unrecognized option~%") name))
(lambda (arg result)
(alist-cons 'argument arg result))
%default-options))
(let* ((opts (parse-options)) (let* ((opts (parse-options))
(args (filter-map (match-lambda (args (filter-map (match-lambda