mirror of
https://git.savannah.gnu.org/git/guile.git
synced 2025-05-01 12:20:26 +02:00
a prettier `guild list'
* module/scripts/list.scm (strip-extensions): Don't list programs without extensions. (main): Be prettier. Parse out a %summary from modules, for a brief synopsis.
This commit is contained in:
parent
9957641b60
commit
5d48015adf
1 changed files with 31 additions and 6 deletions
|
@ -26,6 +26,7 @@
|
||||||
;;; Code:
|
;;; Code:
|
||||||
|
|
||||||
(define-module (scripts list)
|
(define-module (scripts list)
|
||||||
|
#:use-module (ice-9 format)
|
||||||
#:use-module ((srfi srfi-1) #:select (fold append-map))
|
#:use-module ((srfi srfi-1) #:select (fold append-map))
|
||||||
#:export (list-scripts))
|
#:export (list-scripts))
|
||||||
|
|
||||||
|
@ -50,6 +51,10 @@
|
||||||
(or-map (lambda (ext)
|
(or-map (lambda (ext)
|
||||||
(and
|
(and
|
||||||
(string-suffix? ext path)
|
(string-suffix? ext path)
|
||||||
|
;; We really can't be adding e.g. ChangeLog-2008 to the set
|
||||||
|
;; of runnable scripts, just because "" is a valid
|
||||||
|
;; extension, by default. So hack around that here.
|
||||||
|
(not (string-null? ext))
|
||||||
(substring path 0
|
(substring path 0
|
||||||
(- (string-length path) (string-length ext)))))
|
(- (string-length path) (string-length ext)))))
|
||||||
(append %load-compiled-extensions %load-extensions)))
|
(append %load-compiled-extensions %load-extensions)))
|
||||||
|
@ -74,10 +79,30 @@
|
||||||
%load-path)
|
%load-path)
|
||||||
string<?))))
|
string<?))))
|
||||||
|
|
||||||
(define (list-scripts . args)
|
(define (main . args)
|
||||||
(for-each (lambda (x)
|
(display "\
|
||||||
;; would be nice to show a summary.
|
Usage: guild COMMAND [ARGS]
|
||||||
(format #t "~A\n" x))
|
|
||||||
(find-submodules '(scripts))))
|
|
||||||
|
|
||||||
(define main list-scripts)
|
guild runs command-line scripts provided by GNU Guile and related
|
||||||
|
programs. See \"Using Guile Tools\" in the Guile manual, for more
|
||||||
|
information.
|
||||||
|
|
||||||
|
Commands:
|
||||||
|
")
|
||||||
|
|
||||||
|
(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 summary
|
||||||
|
(format #t " ~A ~32t~a\n" name summary)
|
||||||
|
(format #t " ~A\n" name))))
|
||||||
|
(find-submodules '(scripts)))
|
||||||
|
|
||||||
|
(display "\
|
||||||
|
|
||||||
|
If COMMAND is \"list\" or omitted, display available scripts, otherwise
|
||||||
|
COMMAND is run with ARGS.
|
||||||
|
"))
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue