guix-commits
[Top][All Lists]
Advanced

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

08/09: import: Use PARSE-COMMAND-LINE for options.


From: guix-commits
Subject: 08/09: import: Use PARSE-COMMAND-LINE for options.
Date: Wed, 4 Aug 2021 11:23:19 -0400 (EDT)

civodul pushed a commit to branch master
in repository guix.

commit 15452f319c08f5654963dc11425eab01067df087
Author: Sarah Morgensen <iskarian@mgsn.dev>
AuthorDate: Tue Aug 3 11:24:50 2021 -0700

    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>
---
 guix/scripts/import/cpan.scm     |  9 +++------
 guix/scripts/import/cran.scm     |  9 +++------
 guix/scripts/import/crate.scm    | 10 +++-------
 guix/scripts/import/egg.scm      |  9 +++------
 guix/scripts/import/elpa.scm     |  9 +++------
 guix/scripts/import/gem.scm      |  9 +++------
 guix/scripts/import/gnu.scm      |  9 +++------
 guix/scripts/import/go.scm       |  9 +++------
 guix/scripts/import/hackage.scm  |  9 +++------
 guix/scripts/import/json.scm     |  9 +++------
 guix/scripts/import/opam.scm     |  9 +++------
 guix/scripts/import/pypi.scm     |  9 +++------
 guix/scripts/import/stackage.scm |  9 +++------
 guix/scripts/import/texlive.scm  |  9 +++------
 14 files changed, 42 insertions(+), 85 deletions(-)

diff --git a/guix/scripts/import/cpan.scm b/guix/scripts/import/cpan.scm
index 77ffe1f..bdf5a1e 100644
--- a/guix/scripts/import/cpan.scm
+++ b/guix/scripts/import/cpan.scm
@@ -1,5 +1,6 @@
 ;;; GNU Guix --- Functional package management for GNU
 ;;; Copyright © 2014 Eric Bavier <bavier@member.fsf.org>
+;;; Copyright © 2021 Sarah Morgensen <iskarian@mgsn.dev>
 ;;;
 ;;; 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 (parse-options)
     ;; Return the alist of option values.
-    (args-fold* args %options
-                (lambda (opt name arg result)
-                  (leave (G_ "~A: unrecognized option~%") name))
-                (lambda (arg result)
-                  (alist-cons 'argument arg result))
-                %default-options))
+    (parse-command-line args %options (list %default-options)
+                        #:build-options? #f))
 
   (let* ((opts (parse-options))
          (args (filter-map (match-lambda
diff --git a/guix/scripts/import/cran.scm b/guix/scripts/import/cran.scm
index aa3ef32..3e4b038 100644
--- a/guix/scripts/import/cran.scm
+++ b/guix/scripts/import/cran.scm
@@ -2,6 +2,7 @@
 ;;; Copyright © 2014 Eric Bavier <bavier@member.fsf.org>
 ;;; Copyright © 2015, 2017, 2019, 2020 Ricardo Wurmus <rekado@elephly.net>
 ;;; Copyright © 2020 Martin Becze <mjbecze@riseup.net>
+;;; Copyright © 2021 Sarah Morgensen <iskarian@mgsn.dev>
 ;;;
 ;;; 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 (parse-options)
     ;; Return the alist of option values.
-    (args-fold* args %options
-                (lambda (opt name arg result)
-                  (leave (G_ "~A: unrecognized option~%") name))
-                (lambda (arg result)
-                  (alist-cons 'argument arg result))
-                %default-options))
+    (parse-command-line args %options (list %default-options)
+                        #:build-options? #f))
 
   (let* ((opts (parse-options))
          (args (filter-map (match-lambda
diff --git a/guix/scripts/import/crate.scm b/guix/scripts/import/crate.scm
index 3a96def..9715290 100644
--- a/guix/scripts/import/crate.scm
+++ b/guix/scripts/import/crate.scm
@@ -3,6 +3,7 @@
 ;;; Copyright © 2014 David Thompson <davet@gnu.org>
 ;;; Copyright © 2016 David Craven <david@craven.ch>
 ;;; Copyright © 2019, 2020 Martin Becze <mjbecze@riseup.net>
+;;; Copyright © 2021 Sarah Morgensen <iskarian@mgsn.dev>
 ;;;
 ;;; 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 (parse-options)
     ;; Return the alist of option values.
-    (args-fold* args %options
-                (lambda (opt name arg result)
-                  (leave (G_ "~A: unrecognized option~%") name))
-                (lambda (arg result)
-                  (alist-cons 'argument arg result))
-                %default-options))
-
+    (parse-command-line args %options (list %default-options)
+                        #:build-options? #f))
 
   (let* ((opts (parse-options))
          (args (filter-map (match-lambda
diff --git a/guix/scripts/import/egg.scm b/guix/scripts/import/egg.scm
index 7dbd6fc..829cdc2 100644
--- a/guix/scripts/import/egg.scm
+++ b/guix/scripts/import/egg.scm
@@ -1,5 +1,6 @@
 ;;; GNU Guix --- Functional package management for GNU
 ;;; Copyright © 2021 Xinglu Chen <public@yoctocell.xyz>
+;;; Copyright © 2021 Sarah Morgensen <iskarian@mgsn.dev>
 ;;;
 ;;; 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 (parse-options)
     ;; Return the alist of option values.
-    (args-fold* args %options
-                (lambda (opt name arg result)
-                  (leave (G_ "~A: unrecognized option~%") name))
-                (lambda (arg result)
-                  (alist-cons 'argument arg result))
-                %default-options))
+    (parse-command-line args %options (list %default-options)
+                        #:build-options? #f))
 
   (let* ((opts (parse-options))
          (repo (and=> (assoc-ref opts 'repo) string->symbol))
diff --git a/guix/scripts/import/elpa.scm b/guix/scripts/import/elpa.scm
index d6b38e5..052b0cc 100644
--- a/guix/scripts/import/elpa.scm
+++ b/guix/scripts/import/elpa.scm
@@ -2,6 +2,7 @@
 ;;; Copyright © 2015 Federico Beffa <beffa@fbengineering.ch>
 ;;; Copyright © 2018 Oleg Pykhalov <go.wigust@gmail.com>
 ;;; Copyright © 2020 Martin Becze <mjbecze@riseup.net>
+;;; Copyright © 2021 Sarah Morgensen <iskarian@mgsn.dev>
 ;;;
 ;;; 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 (parse-options)
     ;; Return the alist of option values.
-    (args-fold* args %options
-                (lambda (opt name arg result)
-                  (leave (G_ "~A: unrecognized option~%") name))
-                (lambda (arg result)
-                  (alist-cons 'argument arg result))
-                %default-options))
+    (parse-command-line args %options (list %default-options)
+                        #:build-options? #f))
 
   (let* ((opts (parse-options))
          (args (filter-map (match-lambda
diff --git a/guix/scripts/import/gem.scm b/guix/scripts/import/gem.scm
index c64596b..65d2bf1 100644
--- a/guix/scripts/import/gem.scm
+++ b/guix/scripts/import/gem.scm
@@ -1,6 +1,7 @@
 ;;; GNU Guix --- Functional package management for GNU
 ;;; Copyright © 2015 David Thompson <davet@gnu.org>
 ;;; Copyright © 2018 Oleg Pykhalov <go.wigust@gmail.com>
+;;; Copyright © 2021 Sarah Morgensen <iskarian@mgsn.dev>
 ;;;
 ;;; 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 (parse-options)
     ;; Return the alist of option values.
-    (args-fold* args %options
-                (lambda (opt name arg result)
-                  (leave (G_ "~A: unrecognized option~%") name))
-                (lambda (arg result)
-                  (alist-cons 'argument arg result))
-                %default-options))
+    (parse-command-line args %options (list %default-options)
+                        #:build-options? #f))
 
   (let* ((opts (parse-options))
          (args (filter-map (match-lambda
diff --git a/guix/scripts/import/gnu.scm b/guix/scripts/import/gnu.scm
index ae98370..344e363 100644
--- a/guix/scripts/import/gnu.scm
+++ b/guix/scripts/import/gnu.scm
@@ -1,5 +1,6 @@
 ;;; GNU Guix --- Functional package management for GNU
 ;;; Copyright © 2014, 2016 Ludovic Courtès <ludo@gnu.org>
+;;; Copyright © 2021 Sarah Morgensen <iskarian@mgsn.dev>
 ;;;
 ;;; 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 (parse-options)
     ;; Return the alist of option values.
-    (args-fold* args %options
-                (lambda (opt name arg result)
-                  (leave (G_ "~A: unrecognized option~%") name))
-                (lambda (arg result)
-                  (alist-cons 'argument arg result))
-                %default-options))
+    (parse-command-line args %options (list %default-options)
+                        #:build-options? #f))
 
   (let* ((opts (parse-options))
          (args (filter-map (match-lambda
diff --git a/guix/scripts/import/go.scm b/guix/scripts/import/go.scm
index 74e8e60..e08a1e4 100644
--- a/guix/scripts/import/go.scm
+++ b/guix/scripts/import/go.scm
@@ -2,6 +2,7 @@
 ;;; Copyright © 2020 Katherine Cox-Buday <cox.katherine.e@gmail.com>
 ;;; Copyright © 2021 Maxim Cournoyer <maxim.cournoyer@gmail.com>
 ;;; Copyright © 2021 Zheng Junjie <873216071@qq.com>
+;;; Copyright © 2021 Sarah Morgensen <iskarian@mgsn.dev>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -83,12 +84,8 @@ that are not yet in Guix"))
 (define (guix-import-go . args)
   (define (parse-options)
     ;; Return the alist of option values.
-    (args-fold* args %options
-                (lambda (opt name arg result)
-                  (leave (G_ "~A: unrecognized option~%") name))
-                (lambda (arg result)
-                  (alist-cons 'argument arg result))
-                %default-options))
+    (parse-command-line args %options (list %default-options)
+                        #:build-options? #f))
 
   (let* ((opts (parse-options))
          (args (filter-map (match-lambda
diff --git a/guix/scripts/import/hackage.scm b/guix/scripts/import/hackage.scm
index 906dca2..83128fb 100644
--- a/guix/scripts/import/hackage.scm
+++ b/guix/scripts/import/hackage.scm
@@ -1,6 +1,7 @@
 ;;; GNU Guix --- Functional package management for GNU
 ;;; Copyright © 2015 Federico Beffa <beffa@fbengineering.ch>
 ;;; Copyright © 2018 Ricardo Wurmus <rekado@elephly.net>
+;;; Copyright © 2021 Sarah Morgensen <iskarian@mgsn.dev>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -105,12 +106,8 @@ version.\n"))
 (define (guix-import-hackage . args)
   (define (parse-options)
     ;; Return the alist of option values.
-    (args-fold* args %options
-                (lambda (opt name arg result)
-                  (leave (G_ "~A: unrecognized option~%") name))
-                (lambda (arg result)
-                  (alist-cons 'argument arg result))
-                %default-options))
+    (parse-command-line args %options (list %default-options)
+                        #:build-options? #f))
 
   (define (run-importer package-name opts error-fn)
     (let* ((arguments (list
diff --git a/guix/scripts/import/json.scm b/guix/scripts/import/json.scm
index d8d5c3a..a3b5e6d 100644
--- a/guix/scripts/import/json.scm
+++ b/guix/scripts/import/json.scm
@@ -2,6 +2,7 @@
 ;;; Copyright © 2014 Eric Bavier <bavier@member.fsf.org>
 ;;; Copyright © 2015, 2017 Ricardo Wurmus <rekado@elephly.net>
 ;;; Copyright © 2021 Simon Tournier <zimon.toutoune@gmail.com>
+;;; Copyright © 2021 Sarah Morgensen <iskarian@mgsn.dev>
 ;;;
 ;;; 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 (parse-options)
     ;; Return the alist of option values.
-    (args-fold* args %options
-                (lambda (opt name arg result)
-                  (leave (G_ "~A: unrecognized option~%") name))
-                (lambda (arg result)
-                  (alist-cons 'argument arg result))
-                %default-options))
+    (parse-command-line args %options (list %default-options)
+                        #:build-options? #f))
 
   (let* ((opts (parse-options))
          (args (filter-map (match-lambda
diff --git a/guix/scripts/import/opam.scm b/guix/scripts/import/opam.scm
index da93928..64164e7 100644
--- a/guix/scripts/import/opam.scm
+++ b/guix/scripts/import/opam.scm
@@ -1,5 +1,6 @@
 ;;; GNU Guix --- Functional package management for GNU
 ;;; Copyright © 2018 Julien Lepiller <julien@lepiller.eu>
+;;; Copyright © 2021 Sarah Morgensen <iskarian@mgsn.dev>
 ;;;
 ;;; 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 (parse-options)
     ;; Return the alist of option values.
-    (args-fold* args %options
-                (lambda (opt name arg result)
-                  (leave (G_ "~A: unrecognized option~%") name))
-                (lambda (arg result)
-                  (alist-cons 'argument arg result))
-                %default-options))
+    (parse-command-line args %options (list %default-options)
+                        #:build-options? #f))
 
   (let* ((opts (parse-options))
          (repo (and=> (assoc-ref opts 'repo) string->symbol))
diff --git a/guix/scripts/import/pypi.scm b/guix/scripts/import/pypi.scm
index 3316717..9170a0b 100644
--- a/guix/scripts/import/pypi.scm
+++ b/guix/scripts/import/pypi.scm
@@ -1,6 +1,7 @@
 ;;; GNU Guix --- Functional package management for GNU
 ;;; Copyright © 2014 David Thompson <davet@gnu.org>
 ;;; Copyright © 2018 Ricardo Wurmus <rekado@elephly.net>
+;;; Copyright © 2021 Sarah Morgensen <iskarian@mgsn.dev>
 ;;;
 ;;; 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 (parse-options)
     ;; Return the alist of option values.
-    (args-fold* args %options
-                (lambda (opt name arg result)
-                  (leave (G_ "~A: unrecognized option~%") name))
-                (lambda (arg result)
-                  (alist-cons 'argument arg result))
-                %default-options))
+    (parse-command-line args %options (list %default-options)
+                        #:build-options? #f))
 
   (let* ((opts (parse-options))
          (args (filter-map (match-lambda
diff --git a/guix/scripts/import/stackage.scm b/guix/scripts/import/stackage.scm
index d77328d..211ac73 100644
--- a/guix/scripts/import/stackage.scm
+++ b/guix/scripts/import/stackage.scm
@@ -1,6 +1,7 @@
 ;;; GNU Guix --- Functional package management for GNU
 ;;; Copyright © 2017 Federico Beffa <beffa@fbengineering.ch>
 ;;; Copyright © 2018 Ricardo Wurmus <rekado@elephly.net>
+;;; Copyright © 2021 Sarah Morgensen <iskarian@mgsn.dev>
 ;;;
 ;;; 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 (parse-options)
     ;; Return the alist of option values.
-    (args-fold* args %options
-                (lambda (opt name arg result)
-                  (leave (G_ "~A: unrecognized option~%") name))
-                (lambda (arg result)
-                  (alist-cons 'argument arg result))
-                %default-options))
+    (parse-command-line args %options (list %default-options)
+                        #:build-options? #f))
 
   (define (run-importer package-name opts error-fn)
     (let* ((arguments (list
diff --git a/guix/scripts/import/texlive.scm b/guix/scripts/import/texlive.scm
index 1cceee7..6f0818e 100644
--- a/guix/scripts/import/texlive.scm
+++ b/guix/scripts/import/texlive.scm
@@ -1,5 +1,6 @@
 ;;; GNU Guix --- Functional package management for GNU
 ;;; Copyright © 2017 Ricardo Wurmus <rekado@elephly.net>
+;;; Copyright © 2021 Sarah Morgensen <iskarian@mgsn.dev>
 ;;;
 ;;; 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 (parse-options)
     ;; Return the alist of option values.
-    (args-fold* args %options
-                (lambda (opt name arg result)
-                  (leave (G_ "~A: unrecognized option~%") name))
-                (lambda (arg result)
-                  (alist-cons 'argument arg result))
-                %default-options))
+    (parse-command-line args %options (list %default-options)
+                        #:build-options? #f))
 
   (let* ((opts (parse-options))
          (args (filter-map (match-lambda



reply via email to

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