From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp2 ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms11 with LMTPS id MtHgJOEyAmD7TAAA0tVLHw (envelope-from ) for ; Sat, 16 Jan 2021 00:27:13 +0000 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp2 with LMTPS id CK5+IOEyAmBNdgAAB5/wlQ (envelope-from ) for ; Sat, 16 Jan 2021 00:27:13 +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 5D94A940111 for ; Sat, 16 Jan 2021 00:27:13 +0000 (UTC) Received: from localhost ([::1]:59044 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1l0ZQu-0005VY-3K for larch@yhetil.org; Fri, 15 Jan 2021 19:27:12 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:42928) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1l0ZQl-0005V3-G5 for guix-patches@gnu.org; Fri, 15 Jan 2021 19:27:03 -0500 Received: from debbugs.gnu.org ([209.51.188.43]:58688) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1l0ZQl-00048M-96 for guix-patches@gnu.org; Fri, 15 Jan 2021 19:27:03 -0500 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1l0ZQl-0004zV-4z for guix-patches@gnu.org; Fri, 15 Jan 2021 19:27:03 -0500 X-Loop: help-debbugs@gnu.org Subject: [bug#45893] [PATCH v2 3/3] ui: Add command hint. Resent-From: zimoun Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Sat, 16 Jan 2021 00:27:03 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 45893 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 45893@debbugs.gnu.org Received: via spool by 45893-submit@debbugs.gnu.org id=B45893.161075681719159 (code B ref 45893); Sat, 16 Jan 2021 00:27:03 +0000 Received: (at 45893) by debbugs.gnu.org; 16 Jan 2021 00:26:57 +0000 Received: from localhost ([127.0.0.1]:41999 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1l0ZQf-0004yx-Hp for submit@debbugs.gnu.org; Fri, 15 Jan 2021 19:26:57 -0500 Received: from mail-wm1-f52.google.com ([209.85.128.52]:38910) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1l0ZQc-0004yL-F4 for 45893@debbugs.gnu.org; Fri, 15 Jan 2021 19:26:55 -0500 Received: by mail-wm1-f52.google.com with SMTP id y187so9055504wmd.3 for <45893@debbugs.gnu.org>; Fri, 15 Jan 2021 16:26:54 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=UI3+QFZZ1EzTucehI5O8SHkMfSiUn6sNHSzchGcPGmY=; b=sUDAKNwJFMtGx8EVQeKPP/DmuKP0QL10h4yntDWyHakoNTtRhJSYZz3HCKYGz0zJ6r UNn1XaBMJUpuESh2yiz3ZABSknia8F7hz475HJSNCb9LUCK/O2yXOynHTy6SzWvV6Uoj vybHIYvGdH++684I4WBBYhPk8pMKeVqm0ACB0hLzkoe9ebQP8dDuh1aXdOiedYmINoBH Y1vVUnDA9EStcWkqUKFneSKUDALZFV8qRq/+sA9fmLEDy5BjWLV+ld4ILhqT9UYFe4Yv kyVdf1zF1K2nmf+ToiYY2tDO+S3WBlBO4X6EdXMM+tIY/rMyWddhfMEWW/Plf/XGfs08 wdgg== 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=UI3+QFZZ1EzTucehI5O8SHkMfSiUn6sNHSzchGcPGmY=; b=eCWb92vPp1HgS5CLkp+siMZwBgxbdMZGSQRUyc1HGNIv35AIkOz4axYDzlMkA4UpND l64nnmT39WGnAAHjPNBUiHe5gByAUqrKtgRQ2CbcqC7K+yF1cHLBvnaxh6PLmfmVogTQ +SiPgQ+Ioa8nORazOe/EE14yRlTeL5o4UsB+NM4KHH/ZO3X5OFBRSiqI4kx38twWa7gP h2XufWBY6MQS3Fd1lQV6dnmUZIQkAZlaGgxuSJrDbqSu1BoiADm79qxwVQRpWYXTv0w7 6pRFLuQojki4s1OEurrJ8MA8ppXR/J56mhtnrVWKrtjVlhZWINxLA1Ig9klT3fCauBv1 PFIw== X-Gm-Message-State: AOAM531HqWvW72qiXn7qWwhlSuAxZkAcRHOZjiAQgY/R+Rz42Qt1IJEm 6wjRJxsD2kTJg3QuvEz2P3/OaWFyVGg= X-Google-Smtp-Source: ABdhPJw/AMcV2zT4HMzGCQQIUF9Lgh+q0G/WUUU5qeRVygDU3/2jGaKTDRoG7yw0DY3JCQz6Mvj1eA== X-Received: by 2002:a7b:c8cd:: with SMTP id f13mr10549131wml.56.1610756808791; Fri, 15 Jan 2021 16:26:48 -0800 (PST) Received: from lili.univ-paris-diderot.fr ([2a01:e0a:59b:9120:65d2:2476:f637:db1e]) by smtp.gmail.com with ESMTPSA id u16sm4797475wrn.68.2021.01.15.16.26.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Jan 2021 16:26:48 -0800 (PST) From: zimoun Date: Sat, 16 Jan 2021 01:26:34 +0100 Message-Id: <20210116002634.10401-3-zimon.toutoune@gmail.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210116002634.10401-1-zimon.toutoune@gmail.com> References: <865z3xlp2y.fsf@gmail.com> <20210116002634.10401-1-zimon.toutoune@gmail.com> MIME-Version: 1.0 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 X-Migadu-Spam-Score: 2.74 Authentication-Results: aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=gmail.com header.s=20161025 header.b=sUDAKNwJ; 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: 5D94A940111 X-Spam-Score: 2.74 X-Migadu-Scanner: scn0.migadu.com X-TUID: bYIyvczuq4wD * guix/ui.scm (run-guix-command): Add command hint. --- guix/ui.scm | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/guix/ui.scm b/guix/ui.scm index bd504c68da..43c2007594 100644 --- a/guix/ui.scm +++ b/guix/ui.scm @@ -2123,6 +2123,20 @@ Run COMMAND with ARGS.\n")) (define (run-guix-command command . args) "Run COMMAND with the given ARGS. Report an error when COMMAND is not found." + (define (command-hint guess commands) + (define command-names + (map (lambda (command) + (match (command-name command) + ((head tail ...) head))) + commands)) + + (fold (lambda (name res) + (if (string-null? res) + (string-append "@code{" name "}") + (string-append "@code{" name "}, " res))) + "" + (string-closest (symbol->string guess) command-names))) + (define module (catch 'misc-error (lambda () @@ -2139,6 +2153,8 @@ found." (load file) (resolve-interface `(guix extensions ,command))))) (lambda _ + (display-hint (format #f (G_ "Do you mean ~a?") + (command-hint command (commands)))) (format (current-error-port) (G_ "guix: ~a: command not found~%") command) (show-guix-usage)))))) -- 2.29.2