diff options
author | Danny Milosavljevic <dannym@scratchpost.org> | 2021-02-11 19:12:36 +0100 |
---|---|---|
committer | Danny Milosavljevic <dannym@scratchpost.org> | 2021-02-11 19:12:36 +0100 |
commit | abd318ff4b741eac11227778bf2e569ee7b186ff (patch) | |
tree | 6abc09a3e01914d891124e9d0dda0f4e0979c485 /guix/ui.scm | |
parent | 71cb6dfe10540718eb337e7e2248fc809394894b (diff) | |
parent | c5dc87fee840ad620b01637dc4f9ffa5efc9270c (diff) | |
download | guix-patches-abd318ff4b741eac11227778bf2e569ee7b186ff.tar guix-patches-abd318ff4b741eac11227778bf2e569ee7b186ff.tar.gz |
Merge branch 'master' into core-updates
Diffstat (limited to 'guix/ui.scm')
-rw-r--r-- | guix/ui.scm | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/guix/ui.scm b/guix/ui.scm index 45ae14f83c..9cea405456 100644 --- a/guix/ui.scm +++ b/guix/ui.scm @@ -2123,6 +2123,14 @@ 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)) + (string-closest (symbol->string guess) command-names #:threshold 3)) + (define module ;; Check if there is a matching extension. (match (search-path (extension-directories) @@ -2132,9 +2140,13 @@ found." (lambda () (resolve-interface `(guix scripts ,command))) (lambda _ - (format (current-error-port) - (G_ "guix: ~a: command not found~%") command) - (show-guix-usage)))) + (let ((hint (command-hint command (commands)))) + (format (current-error-port) + (G_ "guix: ~a: command not found~%") command) + (when hint + (display-hint (format #f (G_ "Did you mean @code{~a}?") + hint))) + (show-guix-usage))))) (file (load file) (resolve-interface `(guix extensions ,command))))) |