ui: Invite users to try `--help' in the error message.

* guix/ui.scm (show-guix-usage): Mention `guix --help'.
  Suggested by Mark H. Weaver.
  (run-guix-command): Invoke it when a command is not found.
  (guix-main): Adjust accordingly.
This commit is contained in:
Ludovic Courtès 2013-05-10 23:14:26 +02:00
parent e3729544f9
commit 25c936766e
1 changed files with 17 additions and 6 deletions

View File

@ -387,7 +387,8 @@ reporting."
(define (show-guix-usage) (define (show-guix-usage)
(format (current-error-port) (format (current-error-port)
(_ "Usage: guix COMMAND ARGS...~%"))) (_ "Try `guix --help' for more information.~%"))
(exit 1))
(define (command-files) (define (command-files)
"Return the list of source files that define Guix sub-commands." "Return the list of source files that define Guix sub-commands."
@ -428,7 +429,9 @@ found."
(lambda () (lambda ()
(resolve-interface `(guix scripts ,command))) (resolve-interface `(guix scripts ,command)))
(lambda - (lambda -
(leave (_ "~a: command not found~%") command)))) (format (current-error-port)
(_ "guix: ~a: command not found~%") command)
(show-guix-usage))))
(let ((command-main (module-ref module (let ((command-main (module-ref module
(symbol-append 'guix- command)))) (symbol-append 'guix- command))))
@ -443,10 +446,18 @@ found."
(let () (let ()
(define (option? str) (string-prefix? "-" str)) (define (option? str) (string-prefix? "-" str))
(match args (match args
(() (show-guix-usage) (exit 1)) (()
(("--help") (show-guix-help)) (format (current-error-port)
(("--version") (show-version-and-exit "guix")) (_ "guix: missing command name~%"))
(((? option?) args ...) (show-guix-usage) (exit 1)) (show-guix-usage))
(("--help")
(show-guix-help))
(("--version")
(show-version-and-exit "guix"))
(((? option? o) args ...)
(format (current-error-port)
(_ "guix: unrecognized option '~a'~%") o)
(show-guix-usage))
((command args ...) ((command args ...)
(apply run-guix-command (apply run-guix-command
(string->symbol command) (string->symbol command)