GNU bug report logs - #66592
[PATCH] scripts: archive: Check compatibility of command line options.

Previous Next

Package: guix-patches;

Reported by: Simon Tournier <zimon.toutoune <at> gmail.com>

Date: Tue, 17 Oct 2023 13:30:02 UTC

Severity: normal

Tags: patch

Full log


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

From: Simon Tournier <zimon.toutoune <at> gmail.com>
To: 66592 <at> debbugs.gnu.org
Cc: Simon Tournier <zimon.toutoune <at> gmail.com>
Subject: [PATCH v2] scripts: archive: Check compatibility of command line
 options.
Date: Tue, 24 Oct 2023 18:33:10 +0200
Fixes <https://issues.guix.gnu.org/66358>.
Reported by Perry, Daniel J <dperry45 <at> 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 <at> gnu.org>
 ;;; Copyright © 2020 Tobias Geerinckx-Rice <me <at> tobias.gr>
+;;; Copyright © 2023 Simon Tournier <zimon.toutoune <at> 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





This bug report was last modified 304 days ago.

Previous Next


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