mirror of
https://git.savannah.gnu.org/git/guile.git
synced 2025-04-30 20:00:19 +02:00
add support for guild help FOO
* module/scripts/help.scm (main): Add support for guild help FOO.
This commit is contained in:
parent
f4a76a315a
commit
4f0ea6e3ce
1 changed files with 53 additions and 17 deletions
|
@ -27,6 +27,7 @@
|
|||
|
||||
(define-module (scripts help)
|
||||
#:use-module (ice-9 format)
|
||||
#:use-module (ice-9 documentation)
|
||||
#:use-module ((srfi srfi-1) #:select (fold append-map)))
|
||||
|
||||
(define %summary "Show a brief help message.")
|
||||
|
@ -80,7 +81,7 @@
|
|||
%load-path)
|
||||
string<?))))
|
||||
|
||||
(define (main . args)
|
||||
(define (list-commands all?)
|
||||
(display "\
|
||||
Usage: guild COMMAND [ARGS]
|
||||
|
||||
|
@ -91,19 +92,54 @@ Usage: guild COMMAND [ARGS]
|
|||
Commands:
|
||||
")
|
||||
|
||||
(let ((all? (or (equal? args '("--all"))
|
||||
(equal? args '("-a")))))
|
||||
(for-each
|
||||
(lambda (name)
|
||||
(let* ((modname `(scripts ,(string->symbol name)))
|
||||
(mod (resolve-module modname #:ensure #f))
|
||||
(summary (and mod (and=> (module-variable mod '%summary)
|
||||
variable-ref))))
|
||||
(if (and mod
|
||||
(or all?
|
||||
(let ((v (module-variable mod '%include-in-guild-list)))
|
||||
(if v (variable-ref v) #t))))
|
||||
(if summary
|
||||
(format #t " ~A ~23t~a\n" name summary)
|
||||
(format #t " ~A\n" name)))))
|
||||
(find-submodules '(scripts)))))
|
||||
(for-each
|
||||
(lambda (name)
|
||||
(let* ((modname `(scripts ,(string->symbol name)))
|
||||
(mod (resolve-module modname #:ensure #f))
|
||||
(summary (and mod (and=> (module-variable mod '%summary)
|
||||
variable-ref))))
|
||||
(if (and mod
|
||||
(or all?
|
||||
(let ((v (module-variable mod '%include-in-guild-list)))
|
||||
(if v (variable-ref v) #t))))
|
||||
(if summary
|
||||
(format #t " ~A ~23t~a\n" name summary)
|
||||
(format #t " ~A\n" name)))))
|
||||
(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))))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue