all messages for Guix-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* [bug#47464] [PATCH 0/8] scripts: Allow option hint for various subcommands.
@ 2021-03-29 10:16 zimoun
  2021-03-29 10:17 ` [bug#47464] [PATCH 1/8] scripts: describe: Replace 'args-fold*' by 'parse-command-line' zimoun
  2021-04-01 12:57 ` bug#47464: [PATCH 0/8] scripts: Allow option hint for various subcommands Ludovic Courtès
  0 siblings, 2 replies; 10+ messages in thread
From: zimoun @ 2021-03-29 10:16 UTC (permalink / raw)
  To: 47464; +Cc: zimoun

Hi,

The patch set replaces all the 'args-fold*' by 'parse-command-line'.  Doing
so, all the option typos are hinted.

It could be only one commit (squashing) but it appeared me easier in case
something is wrong; I expect nothing! :-)

I have checked trying various combinations.  Note that
"tests/guix-describe.sh" is SKIP because the test does not work when using
worktree.

Well, a double-check is really welcome. :-)


All the remaining subcommands---authenticate, container, git, import, offload
and substitute---needs a rewriting of how they parse the command line
arguments.

Cheers,
simon



zimoun (8):
  scripts: describe: Replace 'args-fold*' by 'parse-command-line'.
  scripts: discover: Replace 'args-fold*' by 'parse-command-line'.
  scripts: download: Replace 'args-fold*' by 'parse-command-line'.
  scripts: edit: Replace 'args-fold*' by 'parse-command-line'.
  scripts: publish: Replace 'args-fold*' by 'parse-command-line'.
  scripts: repl: Replace 'args-fold*' by 'parse-command-line'.
  scripts: search: Replace 'args-fold*' by 'parse-command-line'.
  scripts: show: Replace 'args-fold*' by 'parse-command-line'.

 guix/scripts/describe.scm | 10 ++++------
 guix/scripts/discover.scm | 12 ++++++------
 guix/scripts/download.scm | 17 ++++++++---------
 guix/scripts/edit.scm     | 10 ++++------
 guix/scripts/publish.scm  | 12 ++++++------
 guix/scripts/repl.scm     | 11 +++++------
 guix/scripts/search.scm   |  9 ++++-----
 guix/scripts/show.scm     | 10 ++++------
 8 files changed, 41 insertions(+), 50 deletions(-)


base-commit: 6e7ba45357078b31a369b23f8a9f38302dfcbb10
-- 
2.30.1





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

* [bug#47464] [PATCH 1/8] scripts: describe: Replace 'args-fold*' by 'parse-command-line'.
  2021-03-29 10:16 [bug#47464] [PATCH 0/8] scripts: Allow option hint for various subcommands zimoun
@ 2021-03-29 10:17 ` zimoun
  2021-03-29 10:18   ` [bug#47464] [PATCH 2/8] scripts: discover: " zimoun
                     ` (6 more replies)
  2021-04-01 12:57 ` bug#47464: [PATCH 0/8] scripts: Allow option hint for various subcommands Ludovic Courtès
  1 sibling, 7 replies; 10+ messages in thread
From: zimoun @ 2021-03-29 10:17 UTC (permalink / raw)
  To: 47464; +Cc: zimoun

* guix/scripts/describe.scm (define-command): Replace 'args-fold*' by
'parse-command-line'.
---
 guix/scripts/describe.scm | 10 ++++------
 1 file changed, 4 insertions(+), 6 deletions(-)

diff --git a/guix/scripts/describe.scm b/guix/scripts/describe.scm
index be2279d254..b5f6249176 100644
--- a/guix/scripts/describe.scm
+++ b/guix/scripts/describe.scm
@@ -2,6 +2,7 @@
 ;;; Copyright © 2018, 2019, 2020, 2021 Ludovic Courtès <ludo@gnu.org>
 ;;; Copyright © 2018 Oleg Pykhalov <go.wigust@gmail.com>
 ;;; Copyright © 2020 Ekaitz Zarraga <ekaitz@elenq.tech>
+;;; Copyright © 2021 Simon Tournier <zimon.toutoune@gmail.com>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -286,12 +287,9 @@ text.  The hyperlink links to a web view of COMMIT, when available."
 
 (define-command (guix-describe . args)
   (synopsis "describe the channel revisions currently used")
-  (let* ((opts    (args-fold* args %options
-                              (lambda (opt name arg result)
-                                (leave (G_ "~A: unrecognized option~%")
-                                       name))
-                              cons
-                              %default-options))
+  (let* ((opts    (parse-command-line args %options (list %default-options)
+                              #:build-options? #f
+                              #:argument-handler cons))
          (format  (assq-ref opts 'format))
          (profile (or (assq-ref opts 'profile) (current-profile))))
     (with-error-handling
-- 
2.30.1





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

* [bug#47464] [PATCH 2/8] scripts: discover: Replace 'args-fold*' by 'parse-command-line'.
  2021-03-29 10:17 ` [bug#47464] [PATCH 1/8] scripts: describe: Replace 'args-fold*' by 'parse-command-line' zimoun
@ 2021-03-29 10:18   ` zimoun
  2021-03-29 10:18   ` [bug#47464] [PATCH 3/8] scripts: download: " zimoun
                     ` (5 subsequent siblings)
  6 siblings, 0 replies; 10+ messages in thread
From: zimoun @ 2021-03-29 10:18 UTC (permalink / raw)
  To: 47464; +Cc: zimoun

* guix/scripts/discover.scm (define-command): Replace 'args-fold*' by
'parse-command-line'.
---
 guix/scripts/discover.scm | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/guix/scripts/discover.scm b/guix/scripts/discover.scm
index 6aade81ed1..be1eaa6e95 100644
--- a/guix/scripts/discover.scm
+++ b/guix/scripts/discover.scm
@@ -1,5 +1,6 @@
 ;;; GNU Guix --- Functional package management for GNU
 ;;; Copyright © 2020 Mathieu Othacehe <othacehe@gnu.org>
+;;; Copyright © 2021 Simon Tournier <zimon.toutoune@gmail.com>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -127,12 +128,11 @@ to synchronize with the writer."
   (synopsis "discover Guix related services using Avahi")
 
   (with-error-handling
-    (let* ((opts (args-fold* args %options
-                             (lambda (opt name arg result)
-                               (leave (G_ "~A: unrecognized option~%") name))
-                             (lambda (arg result)
-                               (leave (G_ "~A: extraneous argument~%") arg))
-                             %default-options))
+    (let* ((opts (parse-command-line args %options (list %default-options)
+                                     #:build-options? #f
+                                     #:argument-handler
+                                     (lambda (arg result)
+                                       (leave (G_ "~A: extraneous argument~%") arg))))
            (cache (assoc-ref opts 'cache))
            (publish-file (publish-file cache)))
       (parameterize ((%publish-file publish-file))
-- 
2.30.1





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

* [bug#47464] [PATCH 3/8] scripts: download: Replace 'args-fold*' by 'parse-command-line'.
  2021-03-29 10:17 ` [bug#47464] [PATCH 1/8] scripts: describe: Replace 'args-fold*' by 'parse-command-line' zimoun
  2021-03-29 10:18   ` [bug#47464] [PATCH 2/8] scripts: discover: " zimoun
@ 2021-03-29 10:18   ` zimoun
  2021-03-29 10:18   ` [bug#47464] [PATCH 4/8] scripts: edit: " zimoun
                     ` (4 subsequent siblings)
  6 siblings, 0 replies; 10+ messages in thread
From: zimoun @ 2021-03-29 10:18 UTC (permalink / raw)
  To: 47464; +Cc: zimoun

* guix/scripts/download.scm (define-command): Replace 'args-fold*' by
'parse-command-line'.
---
 guix/scripts/download.scm | 17 ++++++++---------
 1 file changed, 8 insertions(+), 9 deletions(-)

diff --git a/guix/scripts/download.scm b/guix/scripts/download.scm
index ce8dd8b02c..5a91390358 100644
--- a/guix/scripts/download.scm
+++ b/guix/scripts/download.scm
@@ -1,5 +1,6 @@
 ;;; GNU Guix --- Functional package management for GNU
 ;;; Copyright © 2012, 2013, 2015, 2016, 2017, 2020 Ludovic Courtès <ludo@gnu.org>
+;;; Copyright © 2021 Simon Tournier <zimon.toutoune@gmail.com>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -162,15 +163,13 @@ and 'base16' ('hex' and 'hexadecimal' can be used as well).\n"))
 
   (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)
-                  (when (assq 'argument result)
-                    (leave (G_ "~A: extraneous argument~%") arg))
-
-                  (alist-cons 'argument arg result))
-                %default-options))
+    (parse-command-line args %options (list %default-options)
+                        #:build-options? #f
+                        #:argument-handler
+                        (lambda (arg result)
+                          (when (assq 'argument result)
+                            (leave (G_ "~A: extraneous argument~%") arg))
+                          (alist-cons 'argument arg result))))
 
   (with-error-handling
     (let* ((opts  (parse-options))
-- 
2.30.1





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

* [bug#47464] [PATCH 4/8] scripts: edit: Replace 'args-fold*' by 'parse-command-line'.
  2021-03-29 10:17 ` [bug#47464] [PATCH 1/8] scripts: describe: Replace 'args-fold*' by 'parse-command-line' zimoun
  2021-03-29 10:18   ` [bug#47464] [PATCH 2/8] scripts: discover: " zimoun
  2021-03-29 10:18   ` [bug#47464] [PATCH 3/8] scripts: download: " zimoun
@ 2021-03-29 10:18   ` zimoun
  2021-03-29 10:18   ` [bug#47464] [PATCH 5/8] scripts: publish: " zimoun
                     ` (3 subsequent siblings)
  6 siblings, 0 replies; 10+ messages in thread
From: zimoun @ 2021-03-29 10:18 UTC (permalink / raw)
  To: 47464; +Cc: zimoun

* guix/scripts/edit.scm (define-command): Replace 'args-fold*' by
'parse-command-line'.
---
 guix/scripts/edit.scm | 10 ++++------
 1 file changed, 4 insertions(+), 6 deletions(-)

diff --git a/guix/scripts/edit.scm b/guix/scripts/edit.scm
index 49c9d945b6..b4c0507591 100644
--- a/guix/scripts/edit.scm
+++ b/guix/scripts/edit.scm
@@ -1,7 +1,7 @@
 ;;; GNU Guix --- Functional package management for GNU
 ;;; Copyright © 2015, 2016, 2019, 2020 Ludovic Courtès <ludo@gnu.org>
 ;;; Copyright © 2015 Mathieu Lirzin <mthl@gnu.org>
-;;; Copyright © 2020 Simon Tournier <zimon.toutoune@gmail.com>
+;;; Copyright © 2020, 2021 Simon Tournier <zimon.toutoune@gmail.com>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -84,11 +84,9 @@ line."
 
   (define (parse-arguments)
     ;; Return the list of package names.
-    (args-fold* args %options
-                (lambda (opt name arg result)
-                  (leave (G_ "~A: unrecognized option~%") name))
-                cons
-                '()))
+    (parse-command-line args %options (list (list))
+                #:build-options? #f
+                #:argument-handler cons))
 
   (with-error-handling
     (let* ((specs     (reverse (parse-arguments)))
-- 
2.30.1





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

* [bug#47464] [PATCH 5/8] scripts: publish: Replace 'args-fold*' by 'parse-command-line'.
  2021-03-29 10:17 ` [bug#47464] [PATCH 1/8] scripts: describe: Replace 'args-fold*' by 'parse-command-line' zimoun
                     ` (2 preceding siblings ...)
  2021-03-29 10:18   ` [bug#47464] [PATCH 4/8] scripts: edit: " zimoun
@ 2021-03-29 10:18   ` zimoun
  2021-03-29 10:18   ` [bug#47464] [PATCH 6/8] scripts: repl: " zimoun
                     ` (2 subsequent siblings)
  6 siblings, 0 replies; 10+ messages in thread
From: zimoun @ 2021-03-29 10:18 UTC (permalink / raw)
  To: 47464; +Cc: zimoun

* guix/scripts/publish.scm (define-command): Replace 'args-fold*' by
'parse-command-line'.
---
 guix/scripts/publish.scm | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/guix/scripts/publish.scm b/guix/scripts/publish.scm
index fa85088ed0..39bb224cad 100644
--- a/guix/scripts/publish.scm
+++ b/guix/scripts/publish.scm
@@ -3,6 +3,7 @@
 ;;; Copyright © 2020 by Amar M. Singh <nly@disroot.org>
 ;;; Copyright © 2015, 2016, 2017, 2018, 2019, 2020 Ludovic Courtès <ludo@gnu.org>
 ;;; Copyright © 2020 Maxim Cournoyer <maxim.cournoyer@gmail.com>
+;;; Copyright © 2021 Simon Tournier <zimon.toutoune@gmail.com>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -1117,12 +1118,11 @@ methods, return the applicable compression."
   (synopsis "publish build results over HTTP")
 
   (with-error-handling
-    (let* ((opts    (args-fold* args %options
-                                (lambda (opt name arg result)
-                                  (leave (G_ "~A: unrecognized option~%") name))
-                                (lambda (arg result)
-                                  (leave (G_ "~A: extraneous argument~%") arg))
-                                %default-options))
+    (let* ((opts    (parse-command-line args %options (list %default-options)
+                                        #:build-options? #f
+                                        #:argument-handler
+                                        (lambda (arg result)
+                                          (leave (G_ "~A: extraneous argument~%") arg))))
            (advertise?  (assoc-ref opts 'advertise?))
            (user        (assoc-ref opts 'user))
            (port        (assoc-ref opts 'port))
-- 
2.30.1





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

* [bug#47464] [PATCH 6/8] scripts: repl: Replace 'args-fold*' by 'parse-command-line'.
  2021-03-29 10:17 ` [bug#47464] [PATCH 1/8] scripts: describe: Replace 'args-fold*' by 'parse-command-line' zimoun
                     ` (3 preceding siblings ...)
  2021-03-29 10:18   ` [bug#47464] [PATCH 5/8] scripts: publish: " zimoun
@ 2021-03-29 10:18   ` zimoun
  2021-03-29 10:18   ` [bug#47464] [PATCH 7/8] scripts: search: " zimoun
  2021-03-29 10:18   ` [bug#47464] [PATCH 8/8] scripts: show: " zimoun
  6 siblings, 0 replies; 10+ messages in thread
From: zimoun @ 2021-03-29 10:18 UTC (permalink / raw)
  To: 47464; +Cc: zimoun

* guix/scripts/repl.scm (define-command): Replace 'args-fold*' by
'parse-command-line'.
---
 guix/scripts/repl.scm | 11 +++++------
 1 file changed, 5 insertions(+), 6 deletions(-)

diff --git a/guix/scripts/repl.scm b/guix/scripts/repl.scm
index 9f20803efc..50d18c7760 100644
--- a/guix/scripts/repl.scm
+++ b/guix/scripts/repl.scm
@@ -1,6 +1,6 @@
 ;;; GNU Guix --- Functional package management for GNU
 ;;; Copyright © 2018, 2019, 2020 Ludovic Courtès <ludo@gnu.org>
-;;; Copyright © 2020 Simon Tournier <zimon.toutoune@gmail.com>
+;;; Copyright © 2020, 2021 Simon Tournier <zimon.toutoune@gmail.com>
 ;;; Copyright © 2020 Konrad Hinsen <konrad.hinsen@fastmail.net>
 ;;;
 ;;; This file is part of GNU Guix.
@@ -143,14 +143,13 @@ call THUNK."
   (synopsis "read-eval-print loop (REPL) for interactive programming")
 
   (define opts
-    (args-fold* args %options
-                (lambda (opt name arg result)
-                  (leave (G_ "~A: unrecognized option~%") name))
+    (parse-command-line args %options (list %default-options)
+                #:build-options? #f
+                #:argument-handler
                 (lambda (arg result)
                   (append `((script . ,arg)
                             (ignore-dot-guile? . #t))
-                          result))
-                %default-options))
+                          result))))
 
   (define user-config
     (and=> (getenv "HOME")
-- 
2.30.1





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

* [bug#47464] [PATCH 7/8] scripts: search: Replace 'args-fold*' by 'parse-command-line'.
  2021-03-29 10:17 ` [bug#47464] [PATCH 1/8] scripts: describe: Replace 'args-fold*' by 'parse-command-line' zimoun
                     ` (4 preceding siblings ...)
  2021-03-29 10:18   ` [bug#47464] [PATCH 6/8] scripts: repl: " zimoun
@ 2021-03-29 10:18   ` zimoun
  2021-03-29 10:18   ` [bug#47464] [PATCH 8/8] scripts: show: " zimoun
  6 siblings, 0 replies; 10+ messages in thread
From: zimoun @ 2021-03-29 10:18 UTC (permalink / raw)
  To: 47464; +Cc: zimoun

* guix/scripts/search.scm (define-command): Replace 'args-fold*' by
'parse-command-line'.
---
 guix/scripts/search.scm | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/guix/scripts/search.scm b/guix/scripts/search.scm
index 0c9e6af07b..27b9da5278 100644
--- a/guix/scripts/search.scm
+++ b/guix/scripts/search.scm
@@ -1,5 +1,6 @@
 ;;; GNU Guix --- Functional package management for GNU
 ;;; Copyright © 2019, 2020 Ludovic Courtès <ludo@gnu.org>
+;;; Copyright © 2021 Simon Tournier <zimon.toutoune@gmail.com>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -66,11 +67,9 @@ This is an alias for 'guix package -s'.\n"))
           result))
 
   (define opts
-    (args-fold* args %options
-                (lambda (opt name arg . rest)
-                  (leave (G_ "~A: unrecognized option~%") name))
-                handle-argument
-                '()))
+    (parse-command-line args %options (list (list))
+                        #:build-options? #f
+                        #:argument-handler handle-argument))
 
   (unless (assoc-ref opts 'query)
     (leave (G_ "missing arguments: no regular expressions to search for~%")))
-- 
2.30.1





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

* [bug#47464] [PATCH 8/8] scripts: show: Replace 'args-fold*' by 'parse-command-line'.
  2021-03-29 10:17 ` [bug#47464] [PATCH 1/8] scripts: describe: Replace 'args-fold*' by 'parse-command-line' zimoun
                     ` (5 preceding siblings ...)
  2021-03-29 10:18   ` [bug#47464] [PATCH 7/8] scripts: search: " zimoun
@ 2021-03-29 10:18   ` zimoun
  6 siblings, 0 replies; 10+ messages in thread
From: zimoun @ 2021-03-29 10:18 UTC (permalink / raw)
  To: 47464; +Cc: zimoun

* guix/scripts/show.scm (define-command): Replace 'args-fold*' by
'parse-command-line'.
---
 guix/scripts/show.scm | 10 ++++------
 1 file changed, 4 insertions(+), 6 deletions(-)

diff --git a/guix/scripts/show.scm b/guix/scripts/show.scm
index 535d03c1a6..c747eedd21 100644
--- a/guix/scripts/show.scm
+++ b/guix/scripts/show.scm
@@ -1,5 +1,5 @@
 ;;; GNU Guix --- Functional package management for GNU
-;;; Copyright © 2019 Simon Tournier <zimon.toutoune@gmail.com>
+;;; Copyright © 2019, 2021 Simon Tournier <zimon.toutoune@gmail.com>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -66,11 +66,9 @@ This is an alias for 'guix package --show='.\n"))
           result))
 
   (define opts
-    (args-fold* args %options
-                (lambda (opt name arg . rest)
-                  (leave (G_ "~A: unrecognized option~%") name))
-                handle-argument
-                '()))
+    (parse-command-line args %options (list (list))
+                        #:build-options? #f
+                        #:argument-handler handle-argument))
 
   (unless (assoc-ref opts 'query)
     (leave (G_ "missing arguments: no package to show~%")))
-- 
2.30.1





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

* bug#47464: [PATCH 0/8] scripts: Allow option hint for various subcommands.
  2021-03-29 10:16 [bug#47464] [PATCH 0/8] scripts: Allow option hint for various subcommands zimoun
  2021-03-29 10:17 ` [bug#47464] [PATCH 1/8] scripts: describe: Replace 'args-fold*' by 'parse-command-line' zimoun
@ 2021-04-01 12:57 ` Ludovic Courtès
  1 sibling, 0 replies; 10+ messages in thread
From: Ludovic Courtès @ 2021-04-01 12:57 UTC (permalink / raw)
  To: zimoun; +Cc: 47464-done

Hi!

zimoun <zimon.toutoune@gmail.com> skribis:

> The patch set replaces all the 'args-fold*' by 'parse-command-line'.  Doing
> so, all the option typos are hinted.

Yay!

> It could be only one commit (squashing) but it appeared me easier in case
> something is wrong; I expect nothing! :-)
>
> I have checked trying various combinations.  Note that
> "tests/guix-describe.sh" is SKIP because the test does not work when using
> worktree.
>
> Well, a double-check is really welcome. :-)

All the tests pass, LGTM!

> All the remaining subcommands---authenticate, container, git, import, offload
> and substitute---needs a rewriting of how they parse the command line
> arguments.

Future work.

Applied, thanks!

Ludo’.




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

end of thread, other threads:[~2021-04-01 13:01 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-03-29 10:16 [bug#47464] [PATCH 0/8] scripts: Allow option hint for various subcommands zimoun
2021-03-29 10:17 ` [bug#47464] [PATCH 1/8] scripts: describe: Replace 'args-fold*' by 'parse-command-line' zimoun
2021-03-29 10:18   ` [bug#47464] [PATCH 2/8] scripts: discover: " zimoun
2021-03-29 10:18   ` [bug#47464] [PATCH 3/8] scripts: download: " zimoun
2021-03-29 10:18   ` [bug#47464] [PATCH 4/8] scripts: edit: " zimoun
2021-03-29 10:18   ` [bug#47464] [PATCH 5/8] scripts: publish: " zimoun
2021-03-29 10:18   ` [bug#47464] [PATCH 6/8] scripts: repl: " zimoun
2021-03-29 10:18   ` [bug#47464] [PATCH 7/8] scripts: search: " zimoun
2021-03-29 10:18   ` [bug#47464] [PATCH 8/8] scripts: show: " zimoun
2021-04-01 12:57 ` bug#47464: [PATCH 0/8] scripts: Allow option hint for various subcommands Ludovic Courtès

Code repositories for project(s) associated with this external index

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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.