diff options
author | Andy Wingo <wingo@pobox.com> | 2011-01-27 11:24:22 +0100 |
---|---|---|
committer | Andy Wingo <wingo@pobox.com> | 2011-01-27 11:24:22 +0100 |
commit | 9805ffdaf770f7129db31213f1d9319eaa98a84e (patch) | |
tree | 124cae45e592d08b29e6265ca18702e4f9017802 | |
parent | 38a73781e6dd248268c237980351c61bd36004ea (diff) | |
download | guile-9805ffdaf770f7129db31213f1d9319eaa98a84e.tar.gz |
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.
-rwxr-xr-x | meta/guile-tools.in | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/meta/guile-tools.in b/meta/guile-tools.in index 7678a2dc1..cdcb6107a 100755 --- a/meta/guile-tools.in +++ b/meta/guile-tools.in @@ -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))))) |