From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp1 ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms11 with LMTPS id 14dDC1sxAmC9RAAA0tVLHw (envelope-from ) for ; Sat, 16 Jan 2021 00:20:43 +0000 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp1 with LMTPS id YLKMBlsxAmBJXAAAbx9fmQ (envelope-from ) for ; Sat, 16 Jan 2021 00:20:43 +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 988869402B3 for ; Sat, 16 Jan 2021 00:20:42 +0000 (UTC) Received: from localhost ([::1]:56604 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1l0ZKb-00040x-FP for larch@yhetil.org; Fri, 15 Jan 2021 19:20:41 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:42092) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1l0ZJz-000406-FL for guix-patches@gnu.org; Fri, 15 Jan 2021 19:20:04 -0500 Received: from debbugs.gnu.org ([209.51.188.43]:58675) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1l0ZJy-0001dJ-OJ for guix-patches@gnu.org; Fri, 15 Jan 2021 19:20:03 -0500 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1l0ZJy-0004o6-Hv for guix-patches@gnu.org; Fri, 15 Jan 2021 19:20:02 -0500 X-Loop: help-debbugs@gnu.org Subject: [bug#45893] [PATCH v2 0/3] DRAFT: Hint command line typo Resent-From: zimoun Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Sat, 16 Jan 2021 00:20:02 +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.161075638818437 (code B ref 45893); Sat, 16 Jan 2021 00:20:02 +0000 Received: (at 45893) by debbugs.gnu.org; 16 Jan 2021 00:19:48 +0000 Received: from localhost ([127.0.0.1]:41984 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1l0ZJj-0004nJ-Mf for submit@debbugs.gnu.org; Fri, 15 Jan 2021 19:19:47 -0500 Received: from mail-wr1-f41.google.com ([209.85.221.41]:44944) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1l0ZJf-0004n3-OU for 45893@debbugs.gnu.org; Fri, 15 Jan 2021 19:19:46 -0500 Received: by mail-wr1-f41.google.com with SMTP id w5so10903372wrm.11 for <45893@debbugs.gnu.org>; Fri, 15 Jan 2021 16:19:43 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:references:date:in-reply-to:message-id :user-agent:mime-version:content-transfer-encoding; bh=fymLQoDo0SN4mKMadctCi2Z7iFoOUseAsQ0CZH0cZH4=; b=A1TQ994agtNNWjAFVne0UbtnH5/2HQWN2xp68WVMoLew6Ay4x73bkRyaCLwEKf59Mq LNzFWbE5I9mevwIeaUmHkkDgFU68ipgEoIUsk+X74tiotreBeywp5KRDz9zCaGlF/r70 NAK02Hr9Whrn+j2SI4D9OaJ+n5hyhsgP4dsEQg5Un28oLXcUV0mHl4v10Ml6d7nDKDo5 K2yES2S0uG2HUIieEpSrrIZbY8VZzyp0WvpIe1N/pbD1R+iTDPwoCY6Lx9DOeoPyIIF4 G5jqaSniNOCL98t7cuk2toJlvTUOUtzAkol4dgEjB+S2vO9PJTZNtZLLdg90TB8UGWCu btbA== 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:references:date:in-reply-to :message-id:user-agent:mime-version:content-transfer-encoding; bh=fymLQoDo0SN4mKMadctCi2Z7iFoOUseAsQ0CZH0cZH4=; b=aWo13ecL7XDGpIouCQk2K5r5q2F1WDV5SpGscD6vf0tHKKCBvl3JOOC7m+UhX1O+RY st4A5We3zQUozYsVnR8ob3OFWtlJvXRnCMaXCFrU/mk0XDci0zbf4tnhQx4Lv9Z/wrnW qXQhCbe7+Tr1acGJodSIQ7RXOvsjvf56LkjVSBnkagBqiMXjR+6X2YZGzRK0Ik1GP4+v T+65LNWgXFQ3oN/F17rWkuMXTLS663vxDp2yNSC4zlmCbYQXVoAV3eTYfJ64VaUQgSD5 1T9luQfMVlwqRP3RBlOx0nxaNkYZbzLCBGtInzKzqUW7pheMiBnGXeUxXRLsAb+UwQmA GRnA== X-Gm-Message-State: AOAM532ZC4gDOvXJFeylM5Zwup4cwnsaXsfJBT5DAbhy/J7FpxWg+lZW lc3RjVeYE2ZoOC9O2biYq2I= X-Google-Smtp-Source: ABdhPJzj8D/Qorb73MknxFLhFue8EB1Y08Mf+CiKqIA+ExzXbLOeURja4PiJgX9hPSBqIU9CbWqlFA== X-Received: by 2002:adf:94c7:: with SMTP id 65mr15107269wrr.423.1610756377734; Fri, 15 Jan 2021 16:19:37 -0800 (PST) Received: from lili ([2a01:e0a:59b:9120:65d2:2476:f637:db1e]) by smtp.gmail.com with ESMTPSA id l7sm9488002wmg.41.2021.01.15.16.19.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Jan 2021 16:19:37 -0800 (PST) From: zimoun References: <20210115163732.53665-1-zimon.toutoune@gmail.com> Date: Sat, 16 Jan 2021 01:09:41 +0100 In-Reply-To: <20210115163732.53665-1-zimon.toutoune@gmail.com> (zimoun's message of "Fri, 15 Jan 2021 17:37:32 +0100") Message-ID: <865z3xlp2y.fsf@gmail.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.1 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable 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: -1.26 Authentication-Results: aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=gmail.com header.s=20161025 header.b=A1TQ994a; 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: 988869402B3 X-Spam-Score: -1.26 X-Migadu-Scanner: scn0.migadu.com X-TUID: Vt8l+DNQlx9w Hi, Here a v2 with some revamp. It looks like this: --8<---------------cut here---------------start------------->8--- $ ./pre-inst-env guix show --laod-pth hello hint: Do you mean `load-path'? guix show: error: laod-pth: unrecognized option $ ./pre-inst-env guix chow --laod-pth hello hint: Do you mean `show'? guix: chow: command not found Try `guix --help' for more information. $ ./pre-inst-env guix abcde hint: Do you mean `archive', `gc', `pack', `size'? guix: abcde: command not found Try `guix --help' for more information. $ ./pre-inst-env guix show --abcdefijk hello hint: Do you mean `help', `version', `load-path'? guix show: error: abcdefijk: unrecognized option --8<---------------cut here---------------end--------------->8--- First, the v2 remove of car, cdr etc in favor of =E2=80=99match=E2=80=99. = And, I do not know if my Emacs has the correct setup for indentation. Sorry for that. Second, the 3 added pieces are: 1. levenshtein-distance and string-closest in guix/utils.scm (patch 2) 2. option-hint in guix/scripts.scm (patch 2) 3. command-hint in guix/ui.scm (patch 3) #1 eases the reuses. Well, guix/utils.scm because I lacked imagination. The option-hint is only added in =E2=80=99parse-command-line=E2=80=99 and n= ot =E2=80=99args-fold*=E2=80=99 therefore currently this hint does not work fo= r all the subcommand. That=E2=80=99s the reason of the first patch that fixes for = =E2=80=9Cguix search=E2=80=9D and =E2=80=9Cguix show=E2=80=9D. If it is makes sense, I c= an easily replace all the =E2=80=99args-fold*=E2=80=99 by =E2=80=99parse-command-line=E2=80=99. = I am in favor of that for 2 reasons: a) one function to do one thing b) recommend this parse-command-line function for the new extensions Last, in this mood, a hint is added to the subcommand itself. Well, I am not sure it makes sense=E2=80=A6 Well, that=E2=80=99s just a proposal. Ah, I have not been inspired by the commit message. :-) All the best, simon zimoun (3): scripts: search, show: Replace 'args-fold*' by 'parse-command-line'. guix: scripts: Add hint for option typo. ui: Add command hint. guix/scripts.scm | 21 +++++++++++++++++ guix/scripts/search.scm | 7 ++---- guix/scripts/show.scm | 8 ++----- guix/ui.scm | 16 +++++++++++++ guix/utils.scm | 51 ++++++++++++++++++++++++++++++++++++++++- 5 files changed, 91 insertions(+), 12 deletions(-) base-commit: 884f320e7ceb35cb8472510e47fc5f1944675d82 -- 2.29.2