diff --git a/collects/rico/rico.ss b/collects/rico/rico.ss index 7944b04dfb..25ee0bf783 100644 --- a/collects/rico/rico.ss +++ b/collects/rico/rico.ss @@ -1,6 +1,6 @@ #lang scheme/base -(require setup/getinfo - "command-name.ss") +(require "command-name.ss" + "all-tools.ss") (define cmdline (vector->list (current-command-line-arguments))) @@ -23,79 +23,46 @@ (hash-ref hash s) 'ambiguous)))))) -(let* ([dirs (find-relevant-directories '(rico))] - [infos (map get-info/full dirs)] - [tools (make-hash)]) - (for-each (lambda (i d) - (for-each (lambda (entry) - (cond - [(and (list? entry) - (= (length entry) 4) - (string? (car entry)) - (module-path? (cadr entry)) - (string? (caddr entry)) - (or (not (list-ref entry 3)) - (real? (list-ref entry 3)))) - (let ([p (hash-ref tools (car entry) #f)]) - (when p - (fprintf - (current-error-port) - "warning: tool ~s registered twice: ~e and ~e" - (car entry) - (car p) - d))) - (hash-set! tools (car entry) entry)] - [else - (fprintf - (current-error-port) - "warning: ~s provided bad `rico' spec: ~e" - d - entry)])) - (let ([l (i 'rico (lambda () null))]) - (if (list? l) - l - (list l))))) - infos - dirs) - (let ([show-all? - (cond - [(null? cmdline) #f] - [(or (equal? (car cmdline) "--help") - (equal? (car cmdline) "-h")) - #t] - [(regexp-match? #rx"^-" (car cmdline)) - (fprintf (current-error-port) "~a: A flag must follow a command: ~a\n\n" - (find-system-path 'run-file) - (car cmdline)) +(let* ([tools (all-tools)] + [show-all? + (cond + [(null? cmdline) #f] + [(or (equal? (car cmdline) "--help") + (equal? (car cmdline) "-h")) + #t] + [(regexp-match? #rx"^-" (car cmdline)) + (fprintf (current-error-port) "~a: A flag must follow a command: ~a\n\n" + (find-system-path 'run-file) + (car cmdline)) #f] - [(or (hash-ref tools (car cmdline) #f) - (find-by-prefix tools (car cmdline))) - => (lambda (tool) - (if (eq? 'ambiguous tool) - (begin - (fprintf (current-error-port) "~a: Ambiguous command prefix: ~a\n\n" - (find-system-path 'run-file) - (car cmdline)) + [(or (hash-ref tools (car cmdline) #f) + (find-by-prefix tools (car cmdline))) + => (lambda (tool) + (if (eq? 'ambiguous tool) + (begin + (fprintf (current-error-port) "~a: Ambiguous command prefix: ~a\n\n" + (find-system-path 'run-file) + (car cmdline)) #f) (parameterize ([current-command-line-arguments (list->vector (cdr cmdline))] [current-command-name (car tool)]) - (dynamic-require (cadr tool) #f) - (exit))))] - [else - (fprintf (current-error-port) "~a: Unrecognized command: ~a\n\n" - (find-system-path 'run-file) - (car cmdline)) - #f])]) - (fprintf (current-error-port) "Usage: rico