mirror of
https://git.in.rschanz.org/ryan77627/guix.git
synced 2025-01-26 12:39:36 -05:00
ui: Implement `guix --help'.
* guix/ui.scm (command-files, commands, show-guix-help): New procedures. (guix-main): Invoke `show-guix-help' when passed `--help'.
This commit is contained in:
parent
ec5d0a85eb
commit
e31ff8b8d0
1 changed files with 29 additions and 2 deletions
31
guix/ui.scm
31
guix/ui.scm
|
@ -30,6 +30,7 @@ (define-module (guix ui)
|
|||
#: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 @@ (define (args-fold* options unrecognized-option-proc operand-proc . seeds)
|
|||
(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 @@ (define (guix-main arg0 . args)
|
|||
(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 ...)
|
||||
|
|
Loading…
Reference in a new issue