GNU bug report logs -
#50314
[PATCH 0/2] Add hint typo for importers and system actions
Previous Next
Reported by: zimoun <zimon.toutoune <at> gmail.com>
Date: Wed, 1 Sep 2021 09:56:01 UTC
Severity: normal
Tags: patch
Done: Ludovic Courtès <ludo <at> gnu.org>
Bug is archived. No further changes may be made.
To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 50314 in the body.
You can then email your comments to 50314 AT debbugs.gnu.org in the normal way.
Toggle the display of automated, internal messages from the tracker.
Report forwarded
to
guix-patches <at> gnu.org
:
bug#50314
; Package
guix-patches
.
(Wed, 01 Sep 2021 09:56:02 GMT)
Full text and
rfc822 format available.
Acknowledgement sent
to
zimoun <zimon.toutoune <at> gmail.com>
:
New bug report received and forwarded. Copy sent to
guix-patches <at> gnu.org
.
(Wed, 01 Sep 2021 09:56:02 GMT)
Full text and
rfc822 format available.
Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):
Hi,
Instead of,
$ guix import pypy foo
guix import: error: pypy: invalid importer
it becomes
$ ./pre-inst-env guix import pypy foo
guix import: error: pypy: invalid importer
hint: Did you mean `pypi'?
And thanks to Sarah, the --options are also hinted (when typo).
Note that it is not possible to guess which importer is between 'cpan' and
'cran' for the typo 'can'. The first from the list 'importers' is returned,
i.e., 'cpan'.
Last, instead of
$ guix system sarch cuirass
guix system: error: sarch: unknown action
it becomes
$ ./pre-inst-env guix system sarch cuirass
guix system: error: sarch: unknown action
hint: Did you mean `search'?
All the best,
simon
zimoun (2):
import: Add hint for importer typo.
system: Add hint for action typo.
guix/scripts/import.scm | 8 +++++++-
guix/scripts/system.scm | 31 ++++++++++++++++++++-----------
2 files changed, 27 insertions(+), 12 deletions(-)
base-commit: 1a657497acdead9afbeb24db6102f645d7e28ac9
--
2.29.2
Information forwarded
to
guix-patches <at> gnu.org
:
bug#50314
; Package
guix-patches
.
(Wed, 01 Sep 2021 09:59:02 GMT)
Full text and
rfc822 format available.
Message #8 received at 50314 <at> debbugs.gnu.org (full text, mbox):
* 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 <julien <at> lepiller.eu>
;;; Copyright © 2020 Efraim Flashner <efraim <at> flashner.co.il>
;;; Copyright © 2021 Brice Waegeneire <brice <at> waegenei.re>
+;;; Copyright © 2021 Simon Tournier <zimon.toutoune <at> gmail.com>
;;;
;;; 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
Information forwarded
to
guix-patches <at> gnu.org
:
bug#50314
; Package
guix-patches
.
(Wed, 01 Sep 2021 09:59:02 GMT)
Full text and
rfc822 format available.
Message #11 received at 50314 <at> debbugs.gnu.org (full text, mbox):
* guix/scripts/import.scm (define-command): Add hint.
---
guix/scripts/import.scm | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/guix/scripts/import.scm b/guix/scripts/import.scm
index b369a362d0..11e94769bb 100644
--- a/guix/scripts/import.scm
+++ b/guix/scripts/import.scm
@@ -3,6 +3,7 @@
;;; Copyright © 2014 David Thompson <davet <at> gnu.org>
;;; Copyright © 2018 Kyle Meyer <kyle <at> kyleam.com>
;;; Copyright © 2019 Ricardo Wurmus <rekado <at> elephly.net>
+;;; Copyright © 2021 Simon Tournier <zimon.toutoune <at> gmail.com>
;;;
;;; This file is part of GNU Guix.
;;;
@@ -130,4 +131,9 @@ Run IMPORTER with ARGS.\n"))
expressions))
(x
(leave (G_ "'~a' import failed~%") importer))))
- (leave (G_ "~a: invalid importer~%") importer)))))
+ (let ((hint (string-closest importer importers #:threshold 3)))
+ (report-error (G_ "~a: invalid importer~%") importer)
+ (when hint
+ (display-hint
+ (format #f (G_ "Did you mean @code{~a}?~%") hint)))
+ (exit 1))))))
--
2.29.2
Reply sent
to
Ludovic Courtès <ludo <at> gnu.org>
:
You have taken responsibility.
(Tue, 07 Sep 2021 13:52:02 GMT)
Full text and
rfc822 format available.
Notification sent
to
zimoun <zimon.toutoune <at> gmail.com>
:
bug acknowledged by developer.
(Tue, 07 Sep 2021 13:52:02 GMT)
Full text and
rfc822 format available.
Message #16 received at 50314-done <at> debbugs.gnu.org (full text, mbox):
Hello!
zimoun <zimon.toutoune <at> gmail.com> skribis:
> Instead of,
>
> $ guix import pypy foo
> guix import: error: pypy: invalid importer
>
> it becomes
>
> $ ./pre-inst-env guix import pypy foo
> guix import: error: pypy: invalid importer
> hint: Did you mean `pypi'?
>
> And thanks to Sarah, the --options are also hinted (when typo).
[...]
> $ ./pre-inst-env guix system sarch cuirass
> guix system: error: sarch: unknown action
> hint: Did you mean `search'?
Nice!
> import: Add hint for importer typo.
> system: Add hint for action typo.
Applied, thanks! :-)
Ludo’.
bug archived.
Request was from
Debbugs Internal Request <help-debbugs <at> gnu.org>
to
internal_control <at> debbugs.gnu.org
.
(Wed, 06 Oct 2021 11:24:06 GMT)
Full text and
rfc822 format available.
This bug report was last modified 2 years and 202 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.