From 1cf866c863e38bc2a61077e38f416fe3d310e340 Mon Sep 17 00:00:00 2001 From: zimoun Date: Wed, 1 Sep 2021 11:57:55 +0200 Subject: import: Add hint for importer typo. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * guix/scripts/import.scm (define-command): Add hint. Signed-off-by: Ludovic Courtès --- guix/scripts/import.scm | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'guix/scripts') 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 ;;; Copyright © 2018 Kyle Meyer ;;; Copyright © 2019 Ricardo Wurmus +;;; Copyright © 2021 Simon Tournier ;;; ;;; This file is part of GNU Guix. ;;; @@ -130,4 +131,9 @@ (define-command (guix-import . args) 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)))))) -- cgit v1.2.3