[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[bug#71697] [PATCH v5 3/3] scripts: lint: Add hint for checker typo.
From: |
Simon Tournier |
Subject: |
[bug#71697] [PATCH v5 3/3] scripts: lint: Add hint for checker typo. |
Date: |
Fri, 19 Jul 2024 20:38:10 +0200 |
* guix/scripts/lint.scm (option-checker): Add hint for checker typo.
Change-Id: I432c5b0570d2f413b59c2296666f3a4e5fb8c64c
---
guix/scripts/lint.scm | 11 ++++++++++-
1 file changed, 10 insertions(+), 1 deletion(-)
diff --git a/guix/scripts/lint.scm b/guix/scripts/lint.scm
index 2df0cba948..f4aa394686 100644
--- a/guix/scripts/lint.scm
+++ b/guix/scripts/lint.scm
@@ -31,6 +31,7 @@ (define-module (guix scripts lint)
#:use-module (guix packages)
#:use-module (guix lint)
#:use-module (guix ui)
+ #:use-module ((guix utils) #:select (string-closest))
#:use-module (guix store)
#:use-module (guix scripts)
#:use-module (guix scripts build)
@@ -147,7 +148,15 @@ (define (option-checker short-long)
((short long) long)))))
(for-each (lambda (c)
(unless (memq c checker-names)
- (leave (G_ "~a: invalid checker~%") c)))
+ (let* ((name (symbol->string c))
+ (checkers (map symbol->string
checker-names))
+ (hint (string-closest name checkers
+ #:threshold 3)))
+ (report-error (G_ "~a: invalid checker~%") name)
+ (when hint
+ (display-hint
+ (format #f (G_ "Did you mean @code{~a}?~%")
hint)))
+ (exit 1))))
names)
(alist-cons option-name
(filter (lambda (checker)
--
2.41.0