mirror of
https://git.savannah.gnu.org/git/guile.git
synced 2025-04-30 03:40:34 +02:00
guile-tools gracefully errors for missing scripts
* meta/guile-tools.in (find-script): Use the #:ensure arg of resolve-module. (main): Display a comprehensible error message if we don't find a script.
This commit is contained in:
parent
38a73781e6
commit
9805ffdaf7
1 changed files with 9 additions and 5 deletions
|
@ -107,9 +107,7 @@ There is NO WARRANTY, to the extent permitted by law.
|
|||
(find-submodules '(scripts))))
|
||||
|
||||
(define (find-script s)
|
||||
(let ((m (resolve-module (append '(scripts) (list (string->symbol s))))))
|
||||
(and (module-public-interface m)
|
||||
m)))
|
||||
(resolve-module (list 'scripts (string->symbol s)) #:ensure #f))
|
||||
|
||||
(define (getopt args grammar)
|
||||
(catch 'misc-error
|
||||
|
@ -136,6 +134,12 @@ There is NO WARRANTY, to the extent permitted by law.
|
|||
((or (equal? args '())
|
||||
(equal? args '("list")))
|
||||
(list-scripts))
|
||||
((find-script (car args))
|
||||
=> (lambda (mod)
|
||||
(exit (apply (module-ref mod 'main) (cdr args)))))
|
||||
(else
|
||||
(let ((mod (find-script (car args))))
|
||||
(exit (apply (module-ref mod 'main) (cdr args))))))))
|
||||
(format (current-error-port)
|
||||
"guile-tools: unknown script ~s~%" (car args))
|
||||
(format (current-error-port)
|
||||
"Try `guile-tools --help' for more information.~%")
|
||||
(exit 1)))))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue