From 9805ffdaf770f7129db31213f1d9319eaa98a84e Mon Sep 17 00:00:00 2001 From: Andy Wingo Date: Thu, 27 Jan 2011 11:24:22 +0100 Subject: 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. --- meta/guile-tools.in | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) (limited to 'meta') 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))))) -- cgit v1.2.1