;;; schmaltz --- the command-line program (import (schmaltz) (scheme file) (scheme eval) (scheme repl) (srfi 1)) (cond-expand (chicken (render-specials (cons (cons #\@ (lambda (port) ; wrap the next form in `sxml->html' `(begin (import (html-parser)) (sxml->html ,(list 'quasiquote (read port)))))) (render-specials))) (render-unprintables (list (cons "#" (lambda _ '())) (cons "#!eof" (lambda (ch) (list ch #\#)))))) (else)) (define (main args) (define (display-render) (display (render)) (newline)) (define (rout file) (with-input-from-file file display-render)) (cond ((and (null? args) ; input from stdin (char-ready?)) (display-render)) ((member "-" args) (let-values (((fs1 fs2) (break (lambda (x) (equal? x "-")) args))) (for-each rout fs1) (display-render) (for-each rout (cdr fs2)))) ((< 0 (length args)) (for-each rout args)) (else (display "Usage: schmaltz FILE...\n" (current-error-port)) (exit 1)))) (cond-expand ((and chicken (or chicken-script compiling)) (import (chicken process-context)) (main (command-line-arguments))) (chicken) (else (import (scheme process-context)) (main (cdr (command-line)))))