diff options
author | Ludovic Courtès <ludo@gnu.org> | 2013-05-10 12:14:01 +0200 |
---|---|---|
committer | Ludovic Courtès <ludo@gnu.org> | 2013-05-10 12:14:01 +0200 |
commit | ec5d0a85ebdac90f627bfdf0367623eeb88a85af (patch) | |
tree | fe25fb755fac8b9d4ff511fa4a53d58b3548158a | |
parent | a4007c9852f637669b02c6956e568e45ac775924 (diff) | |
download | guix-ec5d0a85ebdac90f627bfdf0367623eeb88a85af.tar guix-ec5d0a85ebdac90f627bfdf0367623eeb88a85af.tar.gz |
ui: Gracefully report "command not found" errors.
* guix/ui.scm (run-guix-command): Can `resolve-interface' errors and
report them with `leave'. Parameterize `program-name' from here.
(guix-main): Remove parameterization of `program-name'.
-rw-r--r-- | guix/ui.scm | 29 |
1 files changed, 18 insertions, 11 deletions
diff --git a/guix/ui.scm b/guix/ui.scm index cd32bfe079..1435575cdd 100644 --- a/guix/ui.scm +++ b/guix/ui.scm @@ -389,17 +389,25 @@ reporting." (format (current-error-port) (_ "Usage: guix COMMAND ARGS...~%"))) -(define (run-guix-command command . args) - ;; TODO: Gracefully report errors - (let* ((module (resolve-interface `(guix scripts ,command))) - (command-main (module-ref module - (symbol-append 'guix- command)))) - (apply command-main args))) - (define program-name ;; Name of the command-line program currently executing, or #f. (make-parameter #f)) +(define (run-guix-command command . args) + "Run COMMAND with the given ARGS. Report an error when COMMAND is not +found." + (define module + (catch 'misc-error + (lambda () + (resolve-interface `(guix scripts ,command))) + (lambda - + (leave (_ "~a: command not found~%") command)))) + + (let ((command-main (module-ref module + (symbol-append 'guix- command)))) + (parameterize ((program-name command)) + (apply command-main args)))) + (define guix-warning-port (make-parameter (current-warning-port))) @@ -413,9 +421,8 @@ reporting." (("--version") (show-version-and-exit "guix")) (((? option?) args ...) (show-guix-usage) (exit 1)) ((command args ...) - (parameterize ((program-name command)) - (apply run-guix-command - (string->symbol command) - args)))))) + (apply run-guix-command + (string->symbol command) + args))))) ;;; ui.scm ends here |