diff options
author | Ludovic Courtès <ludo@gnu.org> | 2013-05-10 12:33:18 +0200 |
---|---|---|
committer | Ludovic Courtès <ludo@gnu.org> | 2013-05-10 12:33:18 +0200 |
commit | e31ff8b8d0a165b3f403a1269455fa38220821e6 (patch) | |
tree | f5854f129ac0a993f2042e90c7e15f86925c550b | |
parent | ec5d0a85ebdac90f627bfdf0367623eeb88a85af (diff) | |
download | guix-e31ff8b8d0a165b3f403a1269455fa38220821e6.tar.gz guix-e31ff8b8d0a165b3f403a1269455fa38220821e6.zip |
ui: Implement `guix --help'.
* guix/ui.scm (command-files, commands, show-guix-help): New procedures.
(guix-main): Invoke `show-guix-help' when passed `--help'.
-rw-r--r-- | guix/ui.scm | 31 |
1 files changed, 29 insertions, 2 deletions
diff --git a/guix/ui.scm b/guix/ui.scm index 1435575cdd..c26ea06cb4 100644 --- a/guix/ui.scm +++ b/guix/ui.scm @@ -30,6 +30,7 @@ #:use-module (srfi srfi-26) #:use-module (srfi srfi-34) #:use-module (srfi srfi-37) + #:autoload (ice-9 ftw) (scandir) #:use-module (ice-9 match) #:use-module (ice-9 format) #:export (_ @@ -385,10 +386,36 @@ reporting." (apply format #f msg args))))) (define (show-guix-usage) - ;; TODO: Dynamically generate a summary of available commands. (format (current-error-port) (_ "Usage: guix COMMAND ARGS...~%"))) +(define (command-files) + "Return the list of source files that define Guix sub-commands." + (define directory + (and=> (search-path %load-path "guix.scm") + (compose (cut string-append <> "/guix/scripts") + dirname))) + + (if directory + (scandir directory (cut string-suffix? ".scm" <>)) + '())) + +(define (commands) + "Return the list of Guix command names." + (map (compose (cut string-drop-right <> 4) + basename) + (command-files))) + +(define (show-guix-help) + (format #t (_ "Usage: guix COMMAND ARGS... +Run COMMAND with ARGS.\n")) + (newline) + (format #t (_ "COMMAND must be one of the sub-commands listed below:\n")) + (newline) + ;; TODO: Display a synopsis of each command. + (format #t "~{ ~a~%~}" (commands)) + (show-bug-report-information)) + (define program-name ;; Name of the command-line program currently executing, or #f. (make-parameter #f)) @@ -417,7 +444,7 @@ found." (define (option? str) (string-prefix? "-" str)) (match args (() (show-guix-usage) (exit 1)) - (("--help") (show-guix-usage)) + (("--help") (show-guix-help)) (("--version") (show-version-and-exit "guix")) (((? option?) args ...) (show-guix-usage) (exit 1)) ((command args ...) |