GNU bug report logs - #49780
[PATCH 00/14] import: Use PARSE-COMMAND-LINE for options.

Previous Next

Package: guix-patches;

Reported by: Sarah Morgensen <iskarian <at> mgsn.dev>

Date: Fri, 30 Jul 2021 03:52:02 UTC

Severity: normal

Tags: patch

Done: Ludovic Courtès <ludo <at> gnu.org>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 49780 in the body.
You can then email your comments to 49780 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to guix-patches <at> gnu.org:
bug#49780; Package guix-patches. (Fri, 30 Jul 2021 03:52:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Sarah Morgensen <iskarian <at> mgsn.dev>:
New bug report received and forwarded. Copy sent to guix-patches <at> gnu.org. (Fri, 30 Jul 2021 03:52:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Sarah Morgensen <iskarian <at> mgsn.dev>
To: guix-patches <at> gnu.org
Subject: [PATCH 00/14] import: Use PARSE-COMMAND-LINE for options.
Date: Thu, 29 Jul 2021 20:51:04 -0700
Hello Guix,

I noticed that we have an ARGS-FOLD* wrapper called PARSE-COMMAND-LINE which has
the same invalid argument message as the importers, the same argument handler,
and has an option hint feature. So let's use that in the importers.

The change is identical across all importers, and the semantics as far as return
value are identical, so this should just be a drop-in.

--
Sarah Morgensen (14):
  import: go: Use PARSE-COMMAND-LINE for options.
  import: egg: Use PARSE-COMMAND-LINE for options.
  import: gem: Use PARSE-COMMAND-LINE for options.
  import: gnu: Use PARSE-COMMAND-LINE for options.
  import: cpan: Use PARSE-COMMAND-LINE for options.
  import: cran: Use PARSE-COMMAND-LINE for options.
  import: elpa: Use PARSE-COMMAND-LINE for options.
  import: json: Use PARSE-COMMAND-LINE for options.
  import: opam: Use PARSE-COMMAND-LINE for options.
  import: pypi: Use PARSE-COMMAND-LINE for options.
  import: crate: Use PARSE-COMMAND-LINE for options.
  import: texlive: Use PARSE-COMMAND-LINE for options.
  import: hackage: Use PARSE-COMMAND-LINE for options.
  import: stackage: Use PARSE-COMMAND-LINE for options.

 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(-)


base-commit: daeef2e7f4f36df7a098c9aee7c03546d8691d39
-- 
2.31.1





Information forwarded to guix-patches <at> gnu.org:
bug#49780; Package guix-patches. (Fri, 30 Jul 2021 03:56:01 GMT) Full text and rfc822 format available.

Message #8 received at 49780 <at> debbugs.gnu.org (full text, mbox):

From: Sarah Morgensen <iskarian <at> mgsn.dev>
To: 49780 <at> debbugs.gnu.org
Subject: [PATCH 01/14] import: go: Use PARSE-COMMAND-LINE for options.
Date: Thu, 29 Jul 2021 20:54:57 -0700
guix/scripts/import/go.scm (guix-import-go)[parse-options]: Use
PARSE-COMMAND-LINE instead of ARGS-FOLD*.
---
 guix/scripts/import/go.scm | 9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)

diff --git a/guix/scripts/import/go.scm b/guix/scripts/import/go.scm
index 74e8e60cce..e08a1e427e 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 <at> gmail.com>
 ;;; Copyright © 2021 Maxim Cournoyer <maxim.cournoyer <at> gmail.com>
 ;;; Copyright © 2021 Zheng Junjie <873216071 <at> qq.com>
+;;; Copyright © 2021 Sarah Morgensen <iskarian <at> 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
-- 
2.31.1





Information forwarded to guix-patches <at> gnu.org:
bug#49780; Package guix-patches. (Fri, 30 Jul 2021 03:56:01 GMT) Full text and rfc822 format available.

Message #11 received at 49780 <at> debbugs.gnu.org (full text, mbox):

From: Sarah Morgensen <iskarian <at> mgsn.dev>
To: 49780 <at> debbugs.gnu.org
Subject: [PATCH 02/14] import: egg: Use PARSE-COMMAND-LINE for options.
Date: Thu, 29 Jul 2021 20:54:58 -0700
guix/scripts/import/egg.scm (guix-import-egg)[parse-options]: Use
PARSE-COMMAND-LINE instead of ARGS-FOLD*.
---
 guix/scripts/import/egg.scm | 9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)

diff --git a/guix/scripts/import/egg.scm b/guix/scripts/import/egg.scm
index 7dbd6fcd5a..829cdc2ca0 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 <at> yoctocell.xyz>
+;;; Copyright © 2021 Sarah Morgensen <iskarian <at> 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))
-- 
2.31.1





Information forwarded to guix-patches <at> gnu.org:
bug#49780; Package guix-patches. (Fri, 30 Jul 2021 03:56:02 GMT) Full text and rfc822 format available.

Message #14 received at 49780 <at> debbugs.gnu.org (full text, mbox):

From: Sarah Morgensen <iskarian <at> mgsn.dev>
To: 49780 <at> debbugs.gnu.org
Subject: [PATCH 03/14] import: gem: Use PARSE-COMMAND-LINE for options.
Date: Thu, 29 Jul 2021 20:54:59 -0700
guix/scripts/import/gem.scm (guix-import-gem)[parse-options]: Use
PARSE-COMMAND-LINE instead of ARGS-FOLD*.
---
 guix/scripts/import/gem.scm | 9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)

diff --git a/guix/scripts/import/gem.scm b/guix/scripts/import/gem.scm
index c64596b514..65d2bf10b4 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 <at> gnu.org>
 ;;; Copyright © 2018 Oleg Pykhalov <go.wigust <at> gmail.com>
+;;; Copyright © 2021 Sarah Morgensen <iskarian <at> 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
-- 
2.31.1





Information forwarded to guix-patches <at> gnu.org:
bug#49780; Package guix-patches. (Fri, 30 Jul 2021 03:56:02 GMT) Full text and rfc822 format available.

Message #17 received at 49780 <at> debbugs.gnu.org (full text, mbox):

From: Sarah Morgensen <iskarian <at> mgsn.dev>
To: 49780 <at> debbugs.gnu.org
Subject: [PATCH 04/14] import: gnu: Use PARSE-COMMAND-LINE for options.
Date: Thu, 29 Jul 2021 20:55:00 -0700
guix/scripts/import/gnu.scm (guix-import-gnu)[parse-options]: Use
PARSE-COMMAND-LINE instead of ARGS-FOLD*.
---
 guix/scripts/import/gnu.scm | 9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)

diff --git a/guix/scripts/import/gnu.scm b/guix/scripts/import/gnu.scm
index ae98370037..344e363abe 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 <at> gnu.org>
+;;; Copyright © 2021 Sarah Morgensen <iskarian <at> 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
-- 
2.31.1





Information forwarded to guix-patches <at> gnu.org:
bug#49780; Package guix-patches. (Fri, 30 Jul 2021 03:56:03 GMT) Full text and rfc822 format available.

Message #20 received at 49780 <at> debbugs.gnu.org (full text, mbox):

From: Sarah Morgensen <iskarian <at> mgsn.dev>
To: 49780 <at> debbugs.gnu.org
Subject: [PATCH 05/14] import: cpan: Use PARSE-COMMAND-LINE for options.
Date: Thu, 29 Jul 2021 20:55:01 -0700
guix/scripts/import/cpan.scm (guix-import-cpan)[parse-options]: Use
PARSE-COMMAND-LINE instead of ARGS-FOLD*.
---
 guix/scripts/import/cpan.scm | 9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)

diff --git a/guix/scripts/import/cpan.scm b/guix/scripts/import/cpan.scm
index 77ffe1f38e..bdf5a1e423 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 <at> member.fsf.org>
+;;; Copyright © 2021 Sarah Morgensen <iskarian <at> 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
-- 
2.31.1





Information forwarded to guix-patches <at> gnu.org:
bug#49780; Package guix-patches. (Fri, 30 Jul 2021 03:56:03 GMT) Full text and rfc822 format available.

Message #23 received at 49780 <at> debbugs.gnu.org (full text, mbox):

From: Sarah Morgensen <iskarian <at> mgsn.dev>
To: 49780 <at> debbugs.gnu.org
Subject: [PATCH 06/14] import: cran: Use PARSE-COMMAND-LINE for options.
Date: Thu, 29 Jul 2021 20:55:02 -0700
guix/scripts/import/cran.scm (guix-import-cran)[parse-options]: Use
PARSE-COMMAND-LINE instead of ARGS-FOLD*.
---
 guix/scripts/import/cran.scm | 9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)

diff --git a/guix/scripts/import/cran.scm b/guix/scripts/import/cran.scm
index aa3ef324e0..3e4b038cc4 100644
--- a/guix/scripts/import/cran.scm
+++ b/guix/scripts/import/cran.scm
@@ -2,6 +2,7 @@
 ;;; Copyright © 2014 Eric Bavier <bavier <at> member.fsf.org>
 ;;; Copyright © 2015, 2017, 2019, 2020 Ricardo Wurmus <rekado <at> elephly.net>
 ;;; Copyright © 2020 Martin Becze <mjbecze <at> riseup.net>
+;;; Copyright © 2021 Sarah Morgensen <iskarian <at> 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
-- 
2.31.1





Information forwarded to guix-patches <at> gnu.org:
bug#49780; Package guix-patches. (Fri, 30 Jul 2021 03:56:03 GMT) Full text and rfc822 format available.

Message #26 received at 49780 <at> debbugs.gnu.org (full text, mbox):

From: Sarah Morgensen <iskarian <at> mgsn.dev>
To: 49780 <at> debbugs.gnu.org
Subject: [PATCH 07/14] import: elpa: Use PARSE-COMMAND-LINE for options.
Date: Thu, 29 Jul 2021 20:55:03 -0700
guix/scripts/import/elpa.scm (guix-import-elpa)[parse-options]: Use
PARSE-COMMAND-LINE instead of ARGS-FOLD*.
---
 guix/scripts/import/elpa.scm | 9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)

diff --git a/guix/scripts/import/elpa.scm b/guix/scripts/import/elpa.scm
index d6b38e5c4b..052b0cc0e7 100644
--- a/guix/scripts/import/elpa.scm
+++ b/guix/scripts/import/elpa.scm
@@ -2,6 +2,7 @@
 ;;; Copyright © 2015 Federico Beffa <beffa <at> fbengineering.ch>
 ;;; Copyright © 2018 Oleg Pykhalov <go.wigust <at> gmail.com>
 ;;; Copyright © 2020 Martin Becze <mjbecze <at> riseup.net>
+;;; Copyright © 2021 Sarah Morgensen <iskarian <at> 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
-- 
2.31.1





Information forwarded to guix-patches <at> gnu.org:
bug#49780; Package guix-patches. (Fri, 30 Jul 2021 03:56:04 GMT) Full text and rfc822 format available.

Message #29 received at 49780 <at> debbugs.gnu.org (full text, mbox):

From: Sarah Morgensen <iskarian <at> mgsn.dev>
To: 49780 <at> debbugs.gnu.org
Subject: [PATCH 08/14] import: json: Use PARSE-COMMAND-LINE for options.
Date: Thu, 29 Jul 2021 20:55:04 -0700
guix/scripts/import/json.scm (guix-import-json)[parse-options]: Use
PARSE-COMMAND-LINE instead of ARGS-FOLD*.
---
 guix/scripts/import/json.scm | 9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)

diff --git a/guix/scripts/import/json.scm b/guix/scripts/import/json.scm
index d8d5c3a4af..a3b5e6d79c 100644
--- a/guix/scripts/import/json.scm
+++ b/guix/scripts/import/json.scm
@@ -2,6 +2,7 @@
 ;;; Copyright © 2014 Eric Bavier <bavier <at> member.fsf.org>
 ;;; Copyright © 2015, 2017 Ricardo Wurmus <rekado <at> elephly.net>
 ;;; Copyright © 2021 Simon Tournier <zimon.toutoune <at> gmail.com>
+;;; Copyright © 2021 Sarah Morgensen <iskarian <at> 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
-- 
2.31.1





Information forwarded to guix-patches <at> gnu.org:
bug#49780; Package guix-patches. (Fri, 30 Jul 2021 03:56:04 GMT) Full text and rfc822 format available.

Message #32 received at 49780 <at> debbugs.gnu.org (full text, mbox):

From: Sarah Morgensen <iskarian <at> mgsn.dev>
To: 49780 <at> debbugs.gnu.org
Subject: [PATCH 09/14] import: opam: Use PARSE-COMMAND-LINE for options.
Date: Thu, 29 Jul 2021 20:55:05 -0700
guix/scripts/import/opam.scm (guix-import-opam)[parse-options]: Use
PARSE-COMMAND-LINE instead of ARGS-FOLD*.
---
 guix/scripts/import/opam.scm | 9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)

diff --git a/guix/scripts/import/opam.scm b/guix/scripts/import/opam.scm
index da9392821c..64164e7cc4 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 <at> lepiller.eu>
+;;; Copyright © 2021 Sarah Morgensen <iskarian <at> 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))
-- 
2.31.1





Information forwarded to guix-patches <at> gnu.org:
bug#49780; Package guix-patches. (Fri, 30 Jul 2021 03:56:04 GMT) Full text and rfc822 format available.

Message #35 received at 49780 <at> debbugs.gnu.org (full text, mbox):

From: Sarah Morgensen <iskarian <at> mgsn.dev>
To: 49780 <at> debbugs.gnu.org
Subject: [PATCH 10/14] import: pypi: Use PARSE-COMMAND-LINE for options.
Date: Thu, 29 Jul 2021 20:55:06 -0700
guix/scripts/import/pypi.scm (guix-import-pypi)[parse-options]: Use
PARSE-COMMAND-LINE instead of ARGS-FOLD*.
---
 guix/scripts/import/pypi.scm | 9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)

diff --git a/guix/scripts/import/pypi.scm b/guix/scripts/import/pypi.scm
index 33167174e2..9170a0b359 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 <at> gnu.org>
 ;;; Copyright © 2018 Ricardo Wurmus <rekado <at> elephly.net>
+;;; Copyright © 2021 Sarah Morgensen <iskarian <at> 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
-- 
2.31.1





Information forwarded to guix-patches <at> gnu.org:
bug#49780; Package guix-patches. (Fri, 30 Jul 2021 03:56:05 GMT) Full text and rfc822 format available.

Message #38 received at 49780 <at> debbugs.gnu.org (full text, mbox):

From: Sarah Morgensen <iskarian <at> mgsn.dev>
To: 49780 <at> debbugs.gnu.org
Subject: [PATCH 11/14] import: crate: Use PARSE-COMMAND-LINE for options.
Date: Thu, 29 Jul 2021 20:55:07 -0700
guix/scripts/import/crate.scm (guix-import-crate)[parse-options]: Use
PARSE-COMMAND-LINE instead of ARGS-FOLD*.
---
 guix/scripts/import/crate.scm | 10 +++-------
 1 file changed, 3 insertions(+), 7 deletions(-)

diff --git a/guix/scripts/import/crate.scm b/guix/scripts/import/crate.scm
index 3a96defb86..97152904ac 100644
--- a/guix/scripts/import/crate.scm
+++ b/guix/scripts/import/crate.scm
@@ -3,6 +3,7 @@
 ;;; Copyright © 2014 David Thompson <davet <at> gnu.org>
 ;;; Copyright © 2016 David Craven <david <at> craven.ch>
 ;;; Copyright © 2019, 2020 Martin Becze <mjbecze <at> riseup.net>
+;;; Copyright © 2021 Sarah Morgensen <iskarian <at> 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
-- 
2.31.1





Information forwarded to guix-patches <at> gnu.org:
bug#49780; Package guix-patches. (Fri, 30 Jul 2021 03:56:05 GMT) Full text and rfc822 format available.

Message #41 received at 49780 <at> debbugs.gnu.org (full text, mbox):

From: Sarah Morgensen <iskarian <at> mgsn.dev>
To: 49780 <at> debbugs.gnu.org
Subject: [PATCH 12/14] import: texlive: Use PARSE-COMMAND-LINE for options.
Date: Thu, 29 Jul 2021 20:55:08 -0700
guix/scripts/import/texlive.scm (guix-import-texlive)[parse-options]:
Use PARSE-COMMAND-LINE instead of ARGS-FOLD*.
---
 guix/scripts/import/texlive.scm | 9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)

diff --git a/guix/scripts/import/texlive.scm b/guix/scripts/import/texlive.scm
index 1cceee7051..6f0818e274 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 <at> elephly.net>
+;;; Copyright © 2021 Sarah Morgensen <iskarian <at> 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
-- 
2.31.1





Information forwarded to guix-patches <at> gnu.org:
bug#49780; Package guix-patches. (Fri, 30 Jul 2021 03:56:06 GMT) Full text and rfc822 format available.

Message #44 received at 49780 <at> debbugs.gnu.org (full text, mbox):

From: Sarah Morgensen <iskarian <at> mgsn.dev>
To: 49780 <at> debbugs.gnu.org
Subject: [PATCH 13/14] import: hackage: Use PARSE-COMMAND-LINE for options.
Date: Thu, 29 Jul 2021 20:55:09 -0700
guix/scripts/import/hackage.scm (guix-import-hackage)[parse-options]:
Use PARSE-COMMAND-LINE instead of ARGS-FOLD*.
---
 guix/scripts/import/hackage.scm | 9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)

diff --git a/guix/scripts/import/hackage.scm b/guix/scripts/import/hackage.scm
index 906dca24b1..83128fb816 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 <at> fbengineering.ch>
 ;;; Copyright © 2018 Ricardo Wurmus <rekado <at> elephly.net>
+;;; Copyright © 2021 Sarah Morgensen <iskarian <at> 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
-- 
2.31.1





Information forwarded to guix-patches <at> gnu.org:
bug#49780; Package guix-patches. (Fri, 30 Jul 2021 03:56:06 GMT) Full text and rfc822 format available.

Message #47 received at 49780 <at> debbugs.gnu.org (full text, mbox):

From: Sarah Morgensen <iskarian <at> mgsn.dev>
To: 49780 <at> debbugs.gnu.org
Subject: [PATCH 14/14] import: stackage: Use PARSE-COMMAND-LINE for options.
Date: Thu, 29 Jul 2021 20:55:10 -0700
guix/scripts/import/stackage.scm (guix-import-stackage)[parse-options]:
Use PARSE-COMMAND-LINE instead of ARGS-FOLD*.
---
 guix/scripts/import/stackage.scm | 9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)

diff --git a/guix/scripts/import/stackage.scm b/guix/scripts/import/stackage.scm
index d77328dcbf..211ac73ada 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 <at> fbengineering.ch>
 ;;; Copyright © 2018 Ricardo Wurmus <rekado <at> elephly.net>
+;;; Copyright © 2021 Sarah Morgensen <iskarian <at> 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
-- 
2.31.1





Information forwarded to guix-patches <at> gnu.org:
bug#49780; Package guix-patches. (Tue, 03 Aug 2021 15:48:01 GMT) Full text and rfc822 format available.

Message #50 received at 49780 <at> debbugs.gnu.org (full text, mbox):

From: Ludovic Courtès <ludo <at> gnu.org>
To: Sarah Morgensen <iskarian <at> mgsn.dev>
Cc: 49780 <at> debbugs.gnu.org
Subject: Re: bug#49780: [PATCH 00/14] import: Use PARSE-COMMAND-LINE for
 options.
Date: Tue, 03 Aug 2021 17:47:14 +0200
Hi Sarah,

Sarah Morgensen <iskarian <at> mgsn.dev> skribis:

> I noticed that we have an ARGS-FOLD* wrapper called PARSE-COMMAND-LINE which has
> the same invalid argument message as the importers, the same argument handler,
> and has an option hint feature. So let's use that in the importers.
>
> The change is identical across all importers, and the semantics as far as return
> value are identical, so this should just be a drop-in.

Neat, that’s a welcome change.  I hope you won’t hate me for suggesting
this, but I think such systematic API evolution changes can go in a
single commit.  WDYT?

Nitpick:

guix/scripts/import/go.scm (guix-import-go)[parse-options]: Use
^
You need a ‘*’ at the beginning of the line.

Thanks!

Ludo’.




Information forwarded to guix-patches <at> gnu.org:
bug#49780; Package guix-patches. (Tue, 03 Aug 2021 18:26:02 GMT) Full text and rfc822 format available.

Message #53 received at 49780 <at> debbugs.gnu.org (full text, mbox):

From: Sarah Morgensen <iskarian <at> mgsn.dev>
To: 49780 <at> debbugs.gnu.org
Cc: Ludovic Courtès <ludo <at> gnu.org>
Subject: [PATCH v2] import: Use PARSE-COMMAND-LINE for options.
Date: Tue,  3 Aug 2021 11:24:50 -0700
* 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.
---
 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 77ffe1f38e..bdf5a1e423 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 <at> member.fsf.org>
+;;; Copyright © 2021 Sarah Morgensen <iskarian <at> 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 aa3ef324e0..3e4b038cc4 100644
--- a/guix/scripts/import/cran.scm
+++ b/guix/scripts/import/cran.scm
@@ -2,6 +2,7 @@
 ;;; Copyright © 2014 Eric Bavier <bavier <at> member.fsf.org>
 ;;; Copyright © 2015, 2017, 2019, 2020 Ricardo Wurmus <rekado <at> elephly.net>
 ;;; Copyright © 2020 Martin Becze <mjbecze <at> riseup.net>
+;;; Copyright © 2021 Sarah Morgensen <iskarian <at> 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 3a96defb86..97152904ac 100644
--- a/guix/scripts/import/crate.scm
+++ b/guix/scripts/import/crate.scm
@@ -3,6 +3,7 @@
 ;;; Copyright © 2014 David Thompson <davet <at> gnu.org>
 ;;; Copyright © 2016 David Craven <david <at> craven.ch>
 ;;; Copyright © 2019, 2020 Martin Becze <mjbecze <at> riseup.net>
+;;; Copyright © 2021 Sarah Morgensen <iskarian <at> 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 7dbd6fcd5a..829cdc2ca0 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 <at> yoctocell.xyz>
+;;; Copyright © 2021 Sarah Morgensen <iskarian <at> 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 d6b38e5c4b..052b0cc0e7 100644
--- a/guix/scripts/import/elpa.scm
+++ b/guix/scripts/import/elpa.scm
@@ -2,6 +2,7 @@
 ;;; Copyright © 2015 Federico Beffa <beffa <at> fbengineering.ch>
 ;;; Copyright © 2018 Oleg Pykhalov <go.wigust <at> gmail.com>
 ;;; Copyright © 2020 Martin Becze <mjbecze <at> riseup.net>
+;;; Copyright © 2021 Sarah Morgensen <iskarian <at> 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 c64596b514..65d2bf10b4 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 <at> gnu.org>
 ;;; Copyright © 2018 Oleg Pykhalov <go.wigust <at> gmail.com>
+;;; Copyright © 2021 Sarah Morgensen <iskarian <at> 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 ae98370037..344e363abe 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 <at> gnu.org>
+;;; Copyright © 2021 Sarah Morgensen <iskarian <at> 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 74e8e60cce..e08a1e427e 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 <at> gmail.com>
 ;;; Copyright © 2021 Maxim Cournoyer <maxim.cournoyer <at> gmail.com>
 ;;; Copyright © 2021 Zheng Junjie <873216071 <at> qq.com>
+;;; Copyright © 2021 Sarah Morgensen <iskarian <at> 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 906dca24b1..83128fb816 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 <at> fbengineering.ch>
 ;;; Copyright © 2018 Ricardo Wurmus <rekado <at> elephly.net>
+;;; Copyright © 2021 Sarah Morgensen <iskarian <at> 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 d8d5c3a4af..a3b5e6d79c 100644
--- a/guix/scripts/import/json.scm
+++ b/guix/scripts/import/json.scm
@@ -2,6 +2,7 @@
 ;;; Copyright © 2014 Eric Bavier <bavier <at> member.fsf.org>
 ;;; Copyright © 2015, 2017 Ricardo Wurmus <rekado <at> elephly.net>
 ;;; Copyright © 2021 Simon Tournier <zimon.toutoune <at> gmail.com>
+;;; Copyright © 2021 Sarah Morgensen <iskarian <at> 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 da9392821c..64164e7cc4 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 <at> lepiller.eu>
+;;; Copyright © 2021 Sarah Morgensen <iskarian <at> 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 33167174e2..9170a0b359 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 <at> gnu.org>
 ;;; Copyright © 2018 Ricardo Wurmus <rekado <at> elephly.net>
+;;; Copyright © 2021 Sarah Morgensen <iskarian <at> 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 d77328dcbf..211ac73ada 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 <at> fbengineering.ch>
 ;;; Copyright © 2018 Ricardo Wurmus <rekado <at> elephly.net>
+;;; Copyright © 2021 Sarah Morgensen <iskarian <at> 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 1cceee7051..6f0818e274 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 <at> elephly.net>
+;;; Copyright © 2021 Sarah Morgensen <iskarian <at> 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

base-commit: e1ddcf75bf9e68a04698733063dd35a3d5b997ee
-- 
2.31.1





Information forwarded to guix-patches <at> gnu.org:
bug#49780; Package guix-patches. (Tue, 03 Aug 2021 18:55:01 GMT) Full text and rfc822 format available.

Message #56 received at 49780 <at> debbugs.gnu.org (full text, mbox):

From: Sarah Morgensen <iskarian <at> mgsn.dev>
To: Ludovic Courtès <ludo <at> gnu.org>
Cc: 49780 <at> debbugs.gnu.org
Subject: Re: bug#49780: [PATCH 00/14] import: Use PARSE-COMMAND-LINE for
 options.
Date: Tue, 03 Aug 2021 11:54:49 -0700
Hi,

Ludovic Courtès <ludo <at> gnu.org> writes:

> Hi Sarah,
>
> Sarah Morgensen <iskarian <at> mgsn.dev> skribis:
>
>> I noticed that we have an ARGS-FOLD* wrapper called PARSE-COMMAND-LINE which has
>> the same invalid argument message as the importers, the same argument handler,
>> and has an option hint feature. So let's use that in the importers.
>>
>> The change is identical across all importers, and the semantics as far as return
>> value are identical, so this should just be a drop-in.
>
> Neat, that’s a welcome change.  I hope you won’t hate me for suggesting
> this, but I think such systematic API evolution changes can go in a
> single commit.  WDYT?

Ha! No problem. v2 sent.

>
> Nitpick:
>
> guix/scripts/import/go.scm (guix-import-go)[parse-options]: Use
> ^
> You need a ‘*’ at the beginning of the line.

Of course I missed that. Fixed in v2. If only etc/committer didn't choke
on it because git-diff decided that literal strings are function
definitions... Looking at it now, git 2.32+ has a built-in function regex
for Scheme, so if we add

  *.scm   diff=scheme

to a .gitattributes file, we should get better diff headers. Quick
testing shows that if we have nested functions, it shows the innermost
one, though. A little modification to the regex can make it show the
topmost one. This is what we want for etc/committer, but is it what we
want elsewhere? I'll send a patch shortly.

>
> Thanks!
>
> Ludo’.

--
Sarah




Reply sent to Ludovic Courtès <ludo <at> gnu.org>:
You have taken responsibility. (Wed, 04 Aug 2021 15:02:02 GMT) Full text and rfc822 format available.

Notification sent to Sarah Morgensen <iskarian <at> mgsn.dev>:
bug acknowledged by developer. (Wed, 04 Aug 2021 15:02:02 GMT) Full text and rfc822 format available.

Message #61 received at 49780-done <at> debbugs.gnu.org (full text, mbox):

From: Ludovic Courtès <ludo <at> gnu.org>
To: Sarah Morgensen <iskarian <at> mgsn.dev>
Cc: 49780-done <at> debbugs.gnu.org
Subject: Re: [PATCH v2] import: Use PARSE-COMMAND-LINE for options.
Date: Wed, 04 Aug 2021 17:01:35 +0200
Hi,

Sarah Morgensen <iskarian <at> mgsn.dev> skribis:

> * 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.

Applied, thank you!

Ludo’.




Information forwarded to guix-patches <at> gnu.org:
bug#49780; Package guix-patches. (Tue, 31 Aug 2021 08:45:02 GMT) Full text and rfc822 format available.

Message #64 received at 49780 <at> debbugs.gnu.org (full text, mbox):

From: zimoun <zimon.toutoune <at> gmail.com>
To: Ludovic Courtès <ludo <at> gnu.org>, Sarah Morgensen
 <iskarian <at> mgsn.dev>
Cc: 49780 <at> debbugs.gnu.org
Subject: Re: [bug#49780] [PATCH 00/14] import: Use PARSE-COMMAND-LINE for
 options.
Date: Tue, 31 Aug 2021 10:24:12 +0200
Hi,

Cool!  Thanks Sarah for the improvement.

On Tue, 03 Aug 2021 at 17:47, Ludovic Courtès <ludo <at> gnu.org> wrote:
> Sarah Morgensen <iskarian <at> mgsn.dev> skribis:
>
>> I noticed that we have an ARGS-FOLD* wrapper called PARSE-COMMAND-LINE which has
>> the same invalid argument message as the importers, the same argument handler,
>> and has an option hint feature. So let's use that in the importers.
>>
>> The change is identical across all importers, and the semantics as far as return
>> value are identical, so this should just be a drop-in.
>
> Neat, that’s a welcome change.  I hope you won’t hate me for suggesting
> this, but I think such systematic API evolution changes can go in a
> single commit.  WDYT?

Well, the previous replacement before the introduction of option hint
had been done with several commits. ;-)

--8<---------------cut here---------------start------------->8---
4056ba3645 scripts: show: Replace 'args-fold*' by 'parse-command-line'.

[...]

946f563d91 scripts: describe: Replace 'args-fold*' by 'parse-command-line'.
--8<---------------cut here---------------end--------------->8---

Whatever, now it is pushed. :-)

Cheers,
simon

PS: For the interested reader, the story is not complete yet, the
subcommands “guix system” does not enjoy such. ;-)




bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Tue, 28 Sep 2021 11:24:11 GMT) Full text and rfc822 format available.

This bug report was last modified 2 years and 204 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.