From patchwork Tue Oct 24 16:33:10 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Simon Tournier X-Patchwork-Id: 55331 Return-Path: X-Original-To: patchwork@mira.cbaines.net Delivered-To: patchwork@mira.cbaines.net Received: by mira.cbaines.net (Postfix, from userid 113) id F0B2D27BBE9; Tue, 24 Oct 2023 17:34:59 +0100 (BST) X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-2.7 required=5.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FROM,MAILING_LIST_MULTI, SPF_HELO_PASS,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.6 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mira.cbaines.net (Postfix) with ESMTPS id 649DA27BBE2 for ; Tue, 24 Oct 2023 17:34:58 +0100 (BST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qvKMX-0001J2-G5; Tue, 24 Oct 2023 12:34:37 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qvKMS-0001Fs-Vz for guix-patches@gnu.org; Tue, 24 Oct 2023 12:34:33 -0400 Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qvKMS-00040k-9F for guix-patches@gnu.org; Tue, 24 Oct 2023 12:34:32 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1qvKMv-0005er-LF for guix-patches@gnu.org; Tue, 24 Oct 2023 12:35:01 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#66592] [PATCH v2] scripts: archive: Check compatibility of command line options. References: In-Reply-To: Resent-From: Simon Tournier Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Tue, 24 Oct 2023 16:35:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 66592 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 66592@debbugs.gnu.org Cc: Simon Tournier Received: via spool by 66592-submit@debbugs.gnu.org id=B66592.169816524321651 (code B ref 66592); Tue, 24 Oct 2023 16:35:01 +0000 Received: (at 66592) by debbugs.gnu.org; 24 Oct 2023 16:34:03 +0000 Received: from localhost ([127.0.0.1]:56521 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qvKLy-0005d9-8e for submit@debbugs.gnu.org; Tue, 24 Oct 2023 12:34:02 -0400 Received: from mail-wm1-x32e.google.com ([2a00:1450:4864:20::32e]:41067) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qvKLr-0005cS-7q for 66592@debbugs.gnu.org; Tue, 24 Oct 2023 12:34:01 -0400 Received: by mail-wm1-x32e.google.com with SMTP id 5b1f17b1804b1-408363c2918so5483645e9.0 for <66592@debbugs.gnu.org>; Tue, 24 Oct 2023 09:33:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1698165199; x=1698769999; darn=debbugs.gnu.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=iEUF6/dJuicCvIQ+Fgil+mE1yc6VnjQGnYAZcplVaxQ=; b=NRbXeeOgm2jrrovamkxZFvYuk3ZkArNqCvniiSTaYSA4d0mdI8pXzRN0sVTEWGDwqi LYGz+Z2THuAnscUD3GtjMr+Uj0qYozdP/qe3ox/0lquFkZL8ndguCuyfnyFLI/NtUFP9 xs5IP8mUKawIE3Bx1TuslhDvMuI6KNeVNYvouS9LZj+OTtgrryaH4YbVmB/fYc0Ca++X q9l5bGB6CRkqKZo0tPLB93Nd/x7rvfqo9IgwqGzOKh63FV8XSKNt4djH5V6xwz10d1XF FbOEg8WFQ25FLmIKRLPDd/As/FPP0f7+uRIULfBdBFqhWTgp5YQTEq8oB6uYyYPsb07k nJSQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1698165199; x=1698769999; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=iEUF6/dJuicCvIQ+Fgil+mE1yc6VnjQGnYAZcplVaxQ=; b=xUp2Nj69nWIfH/xICwJkCw9RpyySfdAlMuO/MfdRWA8np+RafpMlPkwxbW4EievzQi GyqDfKWXdTckoDnNAsR4NwMUPzk5WQZmvO8Q+3p34yGdUocLAM3/Bn4sSmIM4wnp1jnQ GZqz/efZBP8sa41Ap3TvFjS9cHr4gg9HfuvmwFjHornBytQmsMy9NzZxHh0Nw9cDbVM3 rE0jqX5WSGF+mNWnzsNtHMgcGrsOHyvbHtukQh6Nr8XkwsJDjuBKYi2LfyLsPJ2lp4Cd bJwThXtpqX9KVwIUQqwPYoWLhelaEfG5LSvhEjqXKuluMgqebSLjuI4jtzOTEEqgUzeB 7obw== X-Gm-Message-State: AOJu0Yy502mgsOHwDbFbo0tK+VQkVTBayaaEickeot36/1C1egKscQlh WjOk5zn7qU8NgdFq8BIDAAxPrJFhsBw= X-Google-Smtp-Source: AGHT+IFJrn9qebrbhlidIzGQ4cgXeXDDr4E7aL47GP94mjS7ahtj6aASB6fp4TwOWpUL3aGBRHmfqg== X-Received: by 2002:a05:600c:3392:b0:404:72f9:d59a with SMTP id o18-20020a05600c339200b0040472f9d59amr9519364wmp.0.1698165199225; Tue, 24 Oct 2023 09:33:19 -0700 (PDT) Received: from localhost.localdomain ([193.48.40.241]) by smtp.gmail.com with ESMTPSA id l4-20020a05600c4f0400b003fee53feab5sm12547581wmq.10.2023.10.24.09.33.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 24 Oct 2023 09:33:18 -0700 (PDT) From: Simon Tournier Date: Tue, 24 Oct 2023 18:33:10 +0200 Message-Id: <5c26f17bbf1b4cf9872b4a782295260ce337d3fd.1698165008.git.zimon.toutoune@gmail.com> X-Mailer: git-send-email 2.39.2 MIME-Version: 1.0 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org Sender: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org X-getmail-retrieved-from-mailbox: Patches Fixes . Reported by Perry, Daniel J . * 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(-) base-commit: f3714b3d5f51aced4b31447c42d5e89c75e3079f 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 ;;; Copyright © 2020 Tobias Geerinckx-Rice +;;; Copyright © 2023 Simon Tournier ;;; ;;; 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) =>