all messages for Guix-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Simon Tournier <zimon.toutoune@gmail.com>
To: 66592@debbugs.gnu.org
Cc: Simon Tournier <zimon.toutoune@gmail.com>
Subject: [bug#66592] [PATCH v2] scripts: archive: Check compatibility of command line options.
Date: Tue, 24 Oct 2023 18:33:10 +0200	[thread overview]
Message-ID: <5c26f17bbf1b4cf9872b4a782295260ce337d3fd.1698165008.git.zimon.toutoune@gmail.com> (raw)
In-Reply-To: <fb2bfb115372a037e22df39dc194deabf290a58f.1697549017.git.zimon.toutoune@gmail.com>

Fixes <https://issues.guix.gnu.org/66358>.
Reported by Perry, Daniel J <dperry45@gatech.edu>.

* guix/scripts/archive.scm (guix-archive)[compatible-option]: New procedure.
and use it.
---
 guix/scripts/archive.scm | 19 ++++++++++++++++++-
 1 file changed, 18 insertions(+), 1 deletion(-)

diff --git a/guix/scripts/archive.scm b/guix/scripts/archive.scm
index 2b5a55a23f..466aa9c4d7 100644
--- a/guix/scripts/archive.scm
+++ b/guix/scripts/archive.scm
@@ -1,6 +1,7 @@
 ;;; GNU Guix --- Functional package management for GNU
 ;;; Copyright © 2013, 2014, 2015, 2016, 2017, 2019, 2020, 2021 Ludovic Courtès <ludo@gnu.org>
 ;;; Copyright © 2020 Tobias Geerinckx-Rice <me@tobias.gr>
+;;; Copyright © 2023 Simon Tournier <zimon.toutoune@gmail.com>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -375,8 +376,24 @@ (define-command (guix-archive . args)
           (loop (read-line port)
                 (cons line result)))))
 
+  (define* (compatible-option options #:key actions)
+  "Return the OPTIONS if it is compatible with the list of ACTIONS."
+  (let ((some-actions (fold (lambda (action answers)
+                              (if (assoc-ref options action)
+                                  (cons action answers)
+                                  answers))
+                            '()
+                            actions)))
+    (match some-actions
+      ((action)
+       options)
+      ((action other-actions ...)
+       (leave (G_ "the options ~{'~s' ~}are exclusive~%") some-actions)))))
+
   (with-error-handling
-    (let ((opts (parse-command-line args %options (list %default-options))))
+    (let* ((opts (parse-command-line args %options (list %default-options)))
+           (opts (compatible-option opts
+                                    #:actions (list 'authorize 'export 'import))))
       (parameterize ((%graft? (assoc-ref opts 'graft?)))
         (cond ((assoc-ref opts 'generate-key)
                =>

base-commit: f3714b3d5f51aced4b31447c42d5e89c75e3079f
-- 
2.38.1





  reply	other threads:[~2023-10-24 16:34 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-10-17 13:28 [bug#66592] [PATCH] scripts: archive: Check compatibility of command line options Simon Tournier
2023-10-24 16:33 ` Simon Tournier [this message]
2023-10-31 18:01   ` [bug#66592] [PATCH v2] " Maxim Cournoyer
2023-11-30 10:46     ` Simon Tournier
2023-11-30 10:46 ` [bug#66592] [PATCH v3] " Simon Tournier
2023-12-04 22:31   ` Maxim Cournoyer
2024-01-12 10:16     ` Simon Tournier

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=5c26f17bbf1b4cf9872b4a782295260ce337d3fd.1698165008.git.zimon.toutoune@gmail.com \
    --to=zimon.toutoune@gmail.com \
    --cc=66592@debbugs.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.