From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp2 ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms0.migadu.com with LMTPS id +OFsHe9OL2FcNQAAgWs5BA (envelope-from ) for ; Wed, 01 Sep 2021 11:59:11 +0200 Received: from aspmx1.migadu.com ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp2 with LMTPS id mB4/Ge9OL2EzUgAAB5/wlQ (envelope-from ) for ; Wed, 01 Sep 2021 09:59:11 +0000 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id 18C3D7FC1 for ; Wed, 1 Sep 2021 11:59:11 +0200 (CEST) Received: from localhost ([::1]:50044 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mLN1S-0007O1-20 for larch@yhetil.org; Wed, 01 Sep 2021 05:59:10 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:36216) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mLN1K-0007Na-I6 for guix-patches@gnu.org; Wed, 01 Sep 2021 05:59:02 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:53081) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mLN1K-0006l0-AE for guix-patches@gnu.org; Wed, 01 Sep 2021 05:59:02 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1mLN1K-0007DI-9f for guix-patches@gnu.org; Wed, 01 Sep 2021 05:59:02 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#50314] [PATCH 2/2] system: Add hint for action typo. Resent-From: zimoun Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Wed, 01 Sep 2021 09:59:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 50314 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 50314@debbugs.gnu.org Cc: zimoun Received: via spool by 50314-submit@debbugs.gnu.org id=B50314.163049028827635 (code B ref 50314); Wed, 01 Sep 2021 09:59:02 +0000 Received: (at 50314) by debbugs.gnu.org; 1 Sep 2021 09:58:08 +0000 Received: from localhost ([127.0.0.1]:36386 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mLN0S-0007Bf-Ae for submit@debbugs.gnu.org; Wed, 01 Sep 2021 05:58:08 -0400 Received: from mail-wm1-f50.google.com ([209.85.128.50]:45717) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mLN0Q-0007BA-AZ for 50314@debbugs.gnu.org; Wed, 01 Sep 2021 05:58:06 -0400 Received: by mail-wm1-f50.google.com with SMTP id j17-20020a05600c1c1100b002e754875260so1490125wms.4 for <50314@debbugs.gnu.org>; Wed, 01 Sep 2021 02:58:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=8glmS5tCI43DzUtm0jB32OQqUaiGRoXg/FRzZEX/T1Q=; b=eIWv+sBeLVy6c01baO/8XM/ls5GCUPKSI2J4lgOIMGJre0I7iCvwBJjtuMwHeeuq9L s2H8GTMWEjMCQMJAr0Wfk621xDkPxx6mhMISQQbJj4X1TQ7tkYdno4oFry8NAauTybxV 0fRZo2RumClEEXCGkqcaNj6H09GTd/BJyoeIrmCh/b86Sih413oGohIM98nT3Qd7TKBC I6pNr1MwcEJ+W6HJd8Z5LrhGtyre7fpW7nv3PzzRwMsK+6iySckMfLYwZXH9dgPXPYoX jaTgoy50YjcaPP42zLDoaukcN1IP/9SGrzoxXher21ODR868pMJRDHvyULtAWfTDfU1E TdAg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=8glmS5tCI43DzUtm0jB32OQqUaiGRoXg/FRzZEX/T1Q=; b=ny8PSnDhEzkCyJhKpHapY47kWmsD6J/qsIGKVKVo4ea4zBepctkWBd/NcEgCaie6XA Bye17zuDEwaZMCWGwfVEwx25Cta6Pypqi7rzPvYZvaauVMclvrMQ9pqGevyAPbQMup/D 7BQM8C7KBPURkIUcQ9HRHTUkanXrU6H0fB4B0wYfnOVDMrKpCMVwJ2BiBjYvkUupAaS8 wxq22QhBRCaM/aCgBWda0nqXjXTrNjMyuL6lknbDgD87gWC1iVfAzpLhEH7Ko6YuhVRR zg+Of4C6ERo3RfLxnIxm9/UBTWOp4zVBwRoz8g9y3wny9/MeW0XQsFvjEWn+7Evr5Aom GqKw== X-Gm-Message-State: AOAM532xqVoN073d94t7f8LYYTF9rBgRErvW3mL0OtMx5Np+thNyKqFB LSVQ0U7hGtKnZjuHt7oL8mYvMfTe1pSmPg== X-Google-Smtp-Source: ABdhPJxGSOuJ5jsq/TUskWxqfnIikvgx8FIJI98SERCACKS4TNE6qhx/eLfjFertSsqGFWb7uQFJUw== X-Received: by 2002:a1c:730a:: with SMTP id d10mr8870148wmb.59.1630490280343; Wed, 01 Sep 2021 02:58:00 -0700 (PDT) Received: from lili.univ-paris-diderot.fr ([2a01:e0a:59b:9120:65d2:2476:f637:db1e]) by smtp.gmail.com with ESMTPSA id v5sm21772535wru.37.2021.09.01.02.57.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 01 Sep 2021 02:58:00 -0700 (PDT) From: zimoun Date: Wed, 1 Sep 2021 11:57:56 +0200 Message-Id: <20210901095756.13752-2-zimon.toutoune@gmail.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210901095756.13752-1-zimon.toutoune@gmail.com> References: <20210901095756.13752-1-zimon.toutoune@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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+larch=yhetil.org@gnu.org Sender: "Guix-patches" X-Migadu-Flow: FLOW_IN ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1630490351; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding:resent-cc: resent-from:resent-sender:resent-message-id:in-reply-to:in-reply-to: references:references:list-id:list-help:list-unsubscribe: list-subscribe:list-post:dkim-signature; bh=8glmS5tCI43DzUtm0jB32OQqUaiGRoXg/FRzZEX/T1Q=; b=O2sU4xrJp2iuUVg4JOx7oNo47OZECrBvkVjPXowothRT1WnE0NftsAp85Ng2aAqXEmLKql NKaKFxa6cjyF41ENfJV6G/h+JeJSsiSrS5aYwKpLdj5W2jL7eiZ5OGFFuZXnoJl1Hz6tEu zCkG8fTBQgg3FpQdNAbn8AaNRw4rCtPFGCIVZ98fCS93XsOPDRO7ffFScYYRUGQGaLRtW6 AxOwAyux/PpuUyvJsbpgozTxoReBqHAlTrolKRt1mI/e84+fKPWbOKkskAZ1qnsZMxmILo 9F65wa/Cja91JdJd/FacPxohSoFyMWAeJjNwCrmxzjD1seZ+t3F/FP2ruvN03g== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1630490351; a=rsa-sha256; cv=none; b=catGsABqGxBYo6CgMgInlTOduKIF2m6wKj+CcSkqIY4R7Wb+zs9tMJGjGTW1FWqDTcKYxv +iXsBCcefNtdJCQYSjW5+Jh1MRmfMpk6OyowXOj17uFgRw1WcfIYC5LtR17n6SrSwmtxxs UQXbhnpxIW03zEUp/DzhPal2EUgtUyaUvt77PT7jrOCvof7mvxm6icuUK/qLuWrJjX81za 7G9qQ6i/sCIa+BPmRCL/uxtzfcTtNlBqz0c/OeM+EF+wjTZA6Y5Fxds+cWwn14DpdcJFpr ACj4bxKd2z5ud/nNC4I8Rio26Bgxp9tkK0pHoiViGU53/x5CtZNuAJl28yK9DQ== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=gmail.com header.s=20210112 header.b=eIWv+sBe; dmarc=fail reason="SPF not aligned (relaxed)" header.from=gmail.com (policy=none); spf=pass (aspmx1.migadu.com: domain of guix-patches-bounces@gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=guix-patches-bounces@gnu.org X-Migadu-Spam-Score: -1.32 Authentication-Results: aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=gmail.com header.s=20210112 header.b=eIWv+sBe; dmarc=fail reason="SPF not aligned (relaxed)" header.from=gmail.com (policy=none); spf=pass (aspmx1.migadu.com: domain of guix-patches-bounces@gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=guix-patches-bounces@gnu.org X-Migadu-Queue-Id: 18C3D7FC1 X-Spam-Score: -1.32 X-Migadu-Scanner: scn0.migadu.com X-TUID: 1Bot/RIBnEjF * guix/scripts/system.scm (actions): New variable. (define-command): Add hint for action typo. --- guix/scripts/system.scm | 31 ++++++++++++++++++++----------- 1 file changed, 20 insertions(+), 11 deletions(-) diff --git a/guix/scripts/system.scm b/guix/scripts/system.scm index 83bbefd3dc..65eb98e4b2 100644 --- a/guix/scripts/system.scm +++ b/guix/scripts/system.scm @@ -9,6 +9,7 @@ ;;; Copyright © 2020 Julien Lepiller ;;; Copyright © 2020 Efraim Flashner ;;; Copyright © 2021 Brice Waegeneire +;;; Copyright © 2021 Simon Tournier ;;; ;;; This file is part of GNU Guix. ;;; @@ -1152,6 +1153,13 @@ Some ACTIONS support additional ARGS.\n")) ;;; Entry point. ;;; +(define actions '("build" "container" "vm" "vm-image" "image" "disk-image" + "reconfigure" "init" + "extension-graph" "shepherd-graph" + "list-generations" "describe" + "delete-generations" "roll-back" + "switch-generation" "search" "docker-image")) + (define (process-action action args opts) "Process ACTION, a sub-command, with the arguments are listed in ARGS. ACTION must be one of the sub-commands that takes an operating system @@ -1335,17 +1343,18 @@ argument list and OPTS is the option alist." (define (parse-sub-command arg result) ;; Parse sub-command ARG and augment RESULT accordingly. - (if (assoc-ref result 'action) - (alist-cons 'argument arg result) - (let ((action (string->symbol arg))) - (case action - ((build container vm vm-image image disk-image reconfigure init - extension-graph shepherd-graph - list-generations describe - delete-generations roll-back - switch-generation search docker-image) - (alist-cons 'action action result)) - (else (leave (G_ "~a: unknown action~%") action)))))) + (cond ((assoc-ref result 'action) + (alist-cons 'argument arg result)) + ((member arg actions) + (let ((action (string->symbol arg))) + (alist-cons 'action action result))) + (else + (let ((hint (string-closest arg actions #:threshold 3))) + (report-error (G_ "~a: unknown action~%") arg) + (when hint + (display-hint + (format #f (G_ "Did you mean @code{~a}?~%") hint))) + (exit 1))))) (define (match-pair car) ;; Return a procedure that matches a pair with CAR. -- 2.29.2