unofficial mirror of guix-patches@gnu.org 
 help / color / mirror / code / Atom feed
* [bug#49780] [PATCH 00/14] import: Use PARSE-COMMAND-LINE for options.
@ 2021-07-30  3:51 Sarah Morgensen
  2021-07-30  3:54 ` [bug#49780] [PATCH 01/14] import: go: " Sarah Morgensen
                   ` (15 more replies)
  0 siblings, 16 replies; 20+ messages in thread
From: Sarah Morgensen @ 2021-07-30  3:51 UTC (permalink / raw)
  To: 49780

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





^ permalink raw reply	[flat|nested] 20+ messages in thread

* [bug#49780] [PATCH 01/14] import: go: Use PARSE-COMMAND-LINE for options.
  2021-07-30  3:51 [bug#49780] [PATCH 00/14] import: Use PARSE-COMMAND-LINE for options Sarah Morgensen
@ 2021-07-30  3:54 ` Sarah Morgensen
  2021-07-30  3:54 ` [bug#49780] [PATCH 02/14] import: egg: " Sarah Morgensen
                   ` (14 subsequent siblings)
  15 siblings, 0 replies; 20+ messages in thread
From: Sarah Morgensen @ 2021-07-30  3:54 UTC (permalink / raw)
  To: 49780

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@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
-- 
2.31.1





^ permalink raw reply related	[flat|nested] 20+ messages in thread

* [bug#49780] [PATCH 02/14] import: egg: Use PARSE-COMMAND-LINE for options.
  2021-07-30  3:51 [bug#49780] [PATCH 00/14] import: Use PARSE-COMMAND-LINE for options Sarah Morgensen
  2021-07-30  3:54 ` [bug#49780] [PATCH 01/14] import: go: " Sarah Morgensen
@ 2021-07-30  3:54 ` Sarah Morgensen
  2021-07-30  3:54 ` [bug#49780] [PATCH 03/14] import: gem: " Sarah Morgensen
                   ` (13 subsequent siblings)
  15 siblings, 0 replies; 20+ messages in thread
From: Sarah Morgensen @ 2021-07-30  3:54 UTC (permalink / raw)
  To: 49780

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@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))
-- 
2.31.1





^ permalink raw reply related	[flat|nested] 20+ messages in thread

* [bug#49780] [PATCH 03/14] import: gem: Use PARSE-COMMAND-LINE for options.
  2021-07-30  3:51 [bug#49780] [PATCH 00/14] import: Use PARSE-COMMAND-LINE for options Sarah Morgensen
  2021-07-30  3:54 ` [bug#49780] [PATCH 01/14] import: go: " Sarah Morgensen
  2021-07-30  3:54 ` [bug#49780] [PATCH 02/14] import: egg: " Sarah Morgensen
@ 2021-07-30  3:54 ` Sarah Morgensen
  2021-07-30  3:55 ` [bug#49780] [PATCH 04/14] import: gnu: " Sarah Morgensen
                   ` (12 subsequent siblings)
  15 siblings, 0 replies; 20+ messages in thread
From: Sarah Morgensen @ 2021-07-30  3:54 UTC (permalink / raw)
  To: 49780

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@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
-- 
2.31.1





^ permalink raw reply related	[flat|nested] 20+ messages in thread

* [bug#49780] [PATCH 04/14] import: gnu: Use PARSE-COMMAND-LINE for options.
  2021-07-30  3:51 [bug#49780] [PATCH 00/14] import: Use PARSE-COMMAND-LINE for options Sarah Morgensen
                   ` (2 preceding siblings ...)
  2021-07-30  3:54 ` [bug#49780] [PATCH 03/14] import: gem: " Sarah Morgensen
@ 2021-07-30  3:55 ` Sarah Morgensen
  2021-07-30  3:55 ` [bug#49780] [PATCH 05/14] import: cpan: " Sarah Morgensen
                   ` (11 subsequent siblings)
  15 siblings, 0 replies; 20+ messages in thread
From: Sarah Morgensen @ 2021-07-30  3:55 UTC (permalink / raw)
  To: 49780

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@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
-- 
2.31.1





^ permalink raw reply related	[flat|nested] 20+ messages in thread

* [bug#49780] [PATCH 05/14] import: cpan: Use PARSE-COMMAND-LINE for options.
  2021-07-30  3:51 [bug#49780] [PATCH 00/14] import: Use PARSE-COMMAND-LINE for options Sarah Morgensen
                   ` (3 preceding siblings ...)
  2021-07-30  3:55 ` [bug#49780] [PATCH 04/14] import: gnu: " Sarah Morgensen
@ 2021-07-30  3:55 ` Sarah Morgensen
  2021-07-30  3:55 ` [bug#49780] [PATCH 06/14] import: cran: " Sarah Morgensen
                   ` (10 subsequent siblings)
  15 siblings, 0 replies; 20+ messages in thread
From: Sarah Morgensen @ 2021-07-30  3:55 UTC (permalink / raw)
  To: 49780

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@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
-- 
2.31.1





^ permalink raw reply related	[flat|nested] 20+ messages in thread

* [bug#49780] [PATCH 06/14] import: cran: Use PARSE-COMMAND-LINE for options.
  2021-07-30  3:51 [bug#49780] [PATCH 00/14] import: Use PARSE-COMMAND-LINE for options Sarah Morgensen
                   ` (4 preceding siblings ...)
  2021-07-30  3:55 ` [bug#49780] [PATCH 05/14] import: cpan: " Sarah Morgensen
@ 2021-07-30  3:55 ` Sarah Morgensen
  2021-07-30  3:55 ` [bug#49780] [PATCH 07/14] import: elpa: " Sarah Morgensen
                   ` (9 subsequent siblings)
  15 siblings, 0 replies; 20+ messages in thread
From: Sarah Morgensen @ 2021-07-30  3:55 UTC (permalink / raw)
  To: 49780

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@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
-- 
2.31.1





^ permalink raw reply related	[flat|nested] 20+ messages in thread

* [bug#49780] [PATCH 07/14] import: elpa: Use PARSE-COMMAND-LINE for options.
  2021-07-30  3:51 [bug#49780] [PATCH 00/14] import: Use PARSE-COMMAND-LINE for options Sarah Morgensen
                   ` (5 preceding siblings ...)
  2021-07-30  3:55 ` [bug#49780] [PATCH 06/14] import: cran: " Sarah Morgensen
@ 2021-07-30  3:55 ` Sarah Morgensen
  2021-07-30  3:55 ` [bug#49780] [PATCH 08/14] import: json: " Sarah Morgensen
                   ` (8 subsequent siblings)
  15 siblings, 0 replies; 20+ messages in thread
From: Sarah Morgensen @ 2021-07-30  3:55 UTC (permalink / raw)
  To: 49780

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@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
-- 
2.31.1





^ permalink raw reply related	[flat|nested] 20+ messages in thread

* [bug#49780] [PATCH 08/14] import: json: Use PARSE-COMMAND-LINE for options.
  2021-07-30  3:51 [bug#49780] [PATCH 00/14] import: Use PARSE-COMMAND-LINE for options Sarah Morgensen
                   ` (6 preceding siblings ...)
  2021-07-30  3:55 ` [bug#49780] [PATCH 07/14] import: elpa: " Sarah Morgensen
@ 2021-07-30  3:55 ` Sarah Morgensen
  2021-07-30  3:55 ` [bug#49780] [PATCH 09/14] import: opam: " Sarah Morgensen
                   ` (7 subsequent siblings)
  15 siblings, 0 replies; 20+ messages in thread
From: Sarah Morgensen @ 2021-07-30  3:55 UTC (permalink / raw)
  To: 49780

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@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
-- 
2.31.1





^ permalink raw reply related	[flat|nested] 20+ messages in thread

* [bug#49780] [PATCH 09/14] import: opam: Use PARSE-COMMAND-LINE for options.
  2021-07-30  3:51 [bug#49780] [PATCH 00/14] import: Use PARSE-COMMAND-LINE for options Sarah Morgensen
                   ` (7 preceding siblings ...)
  2021-07-30  3:55 ` [bug#49780] [PATCH 08/14] import: json: " Sarah Morgensen
@ 2021-07-30  3:55 ` Sarah Morgensen
  2021-07-30  3:55 ` [bug#49780] [PATCH 10/14] import: pypi: " Sarah Morgensen
                   ` (6 subsequent siblings)
  15 siblings, 0 replies; 20+ messages in thread
From: Sarah Morgensen @ 2021-07-30  3:55 UTC (permalink / raw)
  To: 49780

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@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))
-- 
2.31.1





^ permalink raw reply related	[flat|nested] 20+ messages in thread

* [bug#49780] [PATCH 10/14] import: pypi: Use PARSE-COMMAND-LINE for options.
  2021-07-30  3:51 [bug#49780] [PATCH 00/14] import: Use PARSE-COMMAND-LINE for options Sarah Morgensen
                   ` (8 preceding siblings ...)
  2021-07-30  3:55 ` [bug#49780] [PATCH 09/14] import: opam: " Sarah Morgensen
@ 2021-07-30  3:55 ` Sarah Morgensen
  2021-07-30  3:55 ` [bug#49780] [PATCH 11/14] import: crate: " Sarah Morgensen
                   ` (5 subsequent siblings)
  15 siblings, 0 replies; 20+ messages in thread
From: Sarah Morgensen @ 2021-07-30  3:55 UTC (permalink / raw)
  To: 49780

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@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
-- 
2.31.1





^ permalink raw reply related	[flat|nested] 20+ messages in thread

* [bug#49780] [PATCH 11/14] import: crate: Use PARSE-COMMAND-LINE for options.
  2021-07-30  3:51 [bug#49780] [PATCH 00/14] import: Use PARSE-COMMAND-LINE for options Sarah Morgensen
                   ` (9 preceding siblings ...)
  2021-07-30  3:55 ` [bug#49780] [PATCH 10/14] import: pypi: " Sarah Morgensen
@ 2021-07-30  3:55 ` Sarah Morgensen
  2021-07-30  3:55 ` [bug#49780] [PATCH 12/14] import: texlive: " Sarah Morgensen
                   ` (4 subsequent siblings)
  15 siblings, 0 replies; 20+ messages in thread
From: Sarah Morgensen @ 2021-07-30  3:55 UTC (permalink / raw)
  To: 49780

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@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
-- 
2.31.1





^ permalink raw reply related	[flat|nested] 20+ messages in thread

* [bug#49780] [PATCH 12/14] import: texlive: Use PARSE-COMMAND-LINE for options.
  2021-07-30  3:51 [bug#49780] [PATCH 00/14] import: Use PARSE-COMMAND-LINE for options Sarah Morgensen
                   ` (10 preceding siblings ...)
  2021-07-30  3:55 ` [bug#49780] [PATCH 11/14] import: crate: " Sarah Morgensen
@ 2021-07-30  3:55 ` Sarah Morgensen
  2021-07-30  3:55 ` [bug#49780] [PATCH 13/14] import: hackage: " Sarah Morgensen
                   ` (3 subsequent siblings)
  15 siblings, 0 replies; 20+ messages in thread
From: Sarah Morgensen @ 2021-07-30  3:55 UTC (permalink / raw)
  To: 49780

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@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
-- 
2.31.1





^ permalink raw reply related	[flat|nested] 20+ messages in thread

* [bug#49780] [PATCH 13/14] import: hackage: Use PARSE-COMMAND-LINE for options.
  2021-07-30  3:51 [bug#49780] [PATCH 00/14] import: Use PARSE-COMMAND-LINE for options Sarah Morgensen
                   ` (11 preceding siblings ...)
  2021-07-30  3:55 ` [bug#49780] [PATCH 12/14] import: texlive: " Sarah Morgensen
@ 2021-07-30  3:55 ` Sarah Morgensen
  2021-07-30  3:55 ` [bug#49780] [PATCH 14/14] import: stackage: " Sarah Morgensen
                   ` (2 subsequent siblings)
  15 siblings, 0 replies; 20+ messages in thread
From: Sarah Morgensen @ 2021-07-30  3:55 UTC (permalink / raw)
  To: 49780

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@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
-- 
2.31.1





^ permalink raw reply related	[flat|nested] 20+ messages in thread

* [bug#49780] [PATCH 14/14] import: stackage: Use PARSE-COMMAND-LINE for options.
  2021-07-30  3:51 [bug#49780] [PATCH 00/14] import: Use PARSE-COMMAND-LINE for options Sarah Morgensen
                   ` (12 preceding siblings ...)
  2021-07-30  3:55 ` [bug#49780] [PATCH 13/14] import: hackage: " Sarah Morgensen
@ 2021-07-30  3:55 ` Sarah Morgensen
  2021-08-03 15:47 ` [bug#49780] [PATCH 00/14] import: " Ludovic Courtès
  2021-08-03 18:24 ` [bug#49780] [PATCH v2] " Sarah Morgensen
  15 siblings, 0 replies; 20+ messages in thread
From: Sarah Morgensen @ 2021-07-30  3:55 UTC (permalink / raw)
  To: 49780

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@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
-- 
2.31.1





^ permalink raw reply related	[flat|nested] 20+ messages in thread

* [bug#49780] [PATCH 00/14] import: Use PARSE-COMMAND-LINE for options.
  2021-07-30  3:51 [bug#49780] [PATCH 00/14] import: Use PARSE-COMMAND-LINE for options Sarah Morgensen
                   ` (13 preceding siblings ...)
  2021-07-30  3:55 ` [bug#49780] [PATCH 14/14] import: stackage: " Sarah Morgensen
@ 2021-08-03 15:47 ` Ludovic Courtès
  2021-08-03 18:54   ` Sarah Morgensen
  2021-08-31  8:24   ` zimoun
  2021-08-03 18:24 ` [bug#49780] [PATCH v2] " Sarah Morgensen
  15 siblings, 2 replies; 20+ messages in thread
From: Ludovic Courtès @ 2021-08-03 15:47 UTC (permalink / raw)
  To: Sarah Morgensen; +Cc: 49780

Hi Sarah,

Sarah Morgensen <iskarian@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’.




^ permalink raw reply	[flat|nested] 20+ messages in thread

* [bug#49780] [PATCH v2] import: Use PARSE-COMMAND-LINE for options.
  2021-07-30  3:51 [bug#49780] [PATCH 00/14] import: Use PARSE-COMMAND-LINE for options Sarah Morgensen
                   ` (14 preceding siblings ...)
  2021-08-03 15:47 ` [bug#49780] [PATCH 00/14] import: " Ludovic Courtès
@ 2021-08-03 18:24 ` Sarah Morgensen
  2021-08-04 15:01   ` bug#49780: " Ludovic Courtès
  15 siblings, 1 reply; 20+ messages in thread
From: Sarah Morgensen @ 2021-08-03 18:24 UTC (permalink / raw)
  To: 49780; +Cc: Ludovic Courtès

* 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@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 aa3ef324e0..3e4b038cc4 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 3a96defb86..97152904ac 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 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@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 d6b38e5c4b..052b0cc0e7 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 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@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 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@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 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@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 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@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 d8d5c3a4af..a3b5e6d79c 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 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@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 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@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 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@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 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@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

base-commit: e1ddcf75bf9e68a04698733063dd35a3d5b997ee
-- 
2.31.1





^ permalink raw reply related	[flat|nested] 20+ messages in thread

* [bug#49780] [PATCH 00/14] import: Use PARSE-COMMAND-LINE for options.
  2021-08-03 15:47 ` [bug#49780] [PATCH 00/14] import: " Ludovic Courtès
@ 2021-08-03 18:54   ` Sarah Morgensen
  2021-08-31  8:24   ` zimoun
  1 sibling, 0 replies; 20+ messages in thread
From: Sarah Morgensen @ 2021-08-03 18:54 UTC (permalink / raw)
  To: Ludovic Courtès; +Cc: 49780

Hi,

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

> Hi Sarah,
>
> Sarah Morgensen <iskarian@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




^ permalink raw reply	[flat|nested] 20+ messages in thread

* bug#49780: [PATCH v2] import: Use PARSE-COMMAND-LINE for options.
  2021-08-03 18:24 ` [bug#49780] [PATCH v2] " Sarah Morgensen
@ 2021-08-04 15:01   ` Ludovic Courtès
  0 siblings, 0 replies; 20+ messages in thread
From: Ludovic Courtès @ 2021-08-04 15:01 UTC (permalink / raw)
  To: Sarah Morgensen; +Cc: 49780-done

Hi,

Sarah Morgensen <iskarian@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’.




^ permalink raw reply	[flat|nested] 20+ messages in thread

* [bug#49780] [PATCH 00/14] import: Use PARSE-COMMAND-LINE for options.
  2021-08-03 15:47 ` [bug#49780] [PATCH 00/14] import: " Ludovic Courtès
  2021-08-03 18:54   ` Sarah Morgensen
@ 2021-08-31  8:24   ` zimoun
  1 sibling, 0 replies; 20+ messages in thread
From: zimoun @ 2021-08-31  8:24 UTC (permalink / raw)
  To: Ludovic Courtès, Sarah Morgensen; +Cc: 49780

Hi,

Cool!  Thanks Sarah for the improvement.

On Tue, 03 Aug 2021 at 17:47, Ludovic Courtès <ludo@gnu.org> wrote:
> Sarah Morgensen <iskarian@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. ;-)




^ permalink raw reply	[flat|nested] 20+ messages in thread

end of thread, other threads:[~2021-08-31  8:48 UTC | newest]

Thread overview: 20+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-07-30  3:51 [bug#49780] [PATCH 00/14] import: Use PARSE-COMMAND-LINE for options Sarah Morgensen
2021-07-30  3:54 ` [bug#49780] [PATCH 01/14] import: go: " Sarah Morgensen
2021-07-30  3:54 ` [bug#49780] [PATCH 02/14] import: egg: " Sarah Morgensen
2021-07-30  3:54 ` [bug#49780] [PATCH 03/14] import: gem: " Sarah Morgensen
2021-07-30  3:55 ` [bug#49780] [PATCH 04/14] import: gnu: " Sarah Morgensen
2021-07-30  3:55 ` [bug#49780] [PATCH 05/14] import: cpan: " Sarah Morgensen
2021-07-30  3:55 ` [bug#49780] [PATCH 06/14] import: cran: " Sarah Morgensen
2021-07-30  3:55 ` [bug#49780] [PATCH 07/14] import: elpa: " Sarah Morgensen
2021-07-30  3:55 ` [bug#49780] [PATCH 08/14] import: json: " Sarah Morgensen
2021-07-30  3:55 ` [bug#49780] [PATCH 09/14] import: opam: " Sarah Morgensen
2021-07-30  3:55 ` [bug#49780] [PATCH 10/14] import: pypi: " Sarah Morgensen
2021-07-30  3:55 ` [bug#49780] [PATCH 11/14] import: crate: " Sarah Morgensen
2021-07-30  3:55 ` [bug#49780] [PATCH 12/14] import: texlive: " Sarah Morgensen
2021-07-30  3:55 ` [bug#49780] [PATCH 13/14] import: hackage: " Sarah Morgensen
2021-07-30  3:55 ` [bug#49780] [PATCH 14/14] import: stackage: " Sarah Morgensen
2021-08-03 15:47 ` [bug#49780] [PATCH 00/14] import: " Ludovic Courtès
2021-08-03 18:54   ` Sarah Morgensen
2021-08-31  8:24   ` zimoun
2021-08-03 18:24 ` [bug#49780] [PATCH v2] " Sarah Morgensen
2021-08-04 15:01   ` bug#49780: " Ludovic Courtès

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/guix.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).