1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-04-30 03:40:34 +02:00

add support for guild help FOO

* module/scripts/help.scm (main): Add support for guild help FOO.
This commit is contained in:
Andy Wingo 2011-07-23 18:50:22 +02:00
parent f4a76a315a
commit 4f0ea6e3ce

View file

@ -27,6 +27,7 @@
(define-module (scripts help) (define-module (scripts help)
#:use-module (ice-9 format) #:use-module (ice-9 format)
#:use-module (ice-9 documentation)
#:use-module ((srfi srfi-1) #:select (fold append-map))) #:use-module ((srfi srfi-1) #:select (fold append-map)))
(define %summary "Show a brief help message.") (define %summary "Show a brief help message.")
@ -80,7 +81,7 @@
%load-path) %load-path)
string<?)))) string<?))))
(define (main . args) (define (list-commands all?)
(display "\ (display "\
Usage: guild COMMAND [ARGS] Usage: guild COMMAND [ARGS]
@ -91,8 +92,6 @@ Usage: guild COMMAND [ARGS]
Commands: Commands:
") ")
(let ((all? (or (equal? args '("--all"))
(equal? args '("-a")))))
(for-each (for-each
(lambda (name) (lambda (name)
(let* ((modname `(scripts ,(string->symbol name))) (let* ((modname `(scripts ,(string->symbol name)))
@ -106,4 +105,41 @@ Commands:
(if summary (if summary
(format #t " ~A ~23t~a\n" name summary) (format #t " ~A ~23t~a\n" name summary)
(format #t " ~A\n" name))))) (format #t " ~A\n" name)))))
(find-submodules '(scripts))))) (find-submodules '(scripts)))
(display "
For help on a specific command, try \"guild help COMMAND\".
"))
(define (module-commentary mod)
(file-commentary
(%search-load-path (module-filename mod))))
(define (main . args)
(cond
((null? args)
(list-commands #f))
((or (equal? args '("--all")) (equal? args '("-a")))
(list-commands #t))
((not (string-prefix? "-" (car args)))
;; help for particular command
(let* ((name (car args))
(mod (resolve-module `(scripts ,(string->symbol name))
#:ensure #f)))
(if mod
(let ((commentary (module-commentary mod)))
(if commentary
(display commentary)
(format #t "No documentation found for command \"~a\".\n"
name)))
(begin
(format #t "No command named \"~a\".\n" name)
(exit 1)))))
(else
(display "Usage: guild help
guild help --all
guild help COMMAND
Show a help on guild commands. With --all, show arcane incantations as
well. With COMMAND, show more detailed help for a particular command.
")
(exit 1))))