;;; (jimmy main) --- the program (import (chicken file) (chicken port) (chicken process-context) (jimmy main) args) (define opts (list (args:make-option (t to) (required: "FORMAT") (string-append "Translate input to FORMAT." " One of `gemini', `html', or" " a filename.")) (args:make-option (n no-extensions) #:none "Don't use gemtext extensions.") (args:make-option (T template) (required: "TEMPLATE") "Wrap the generated text in TEMPLATE.") (args:make-option (h help) #:none "Display this text" (usage 0)))) (define (usage #!optional (exit-code 1)) (with-output-to-port (current-error-port) (lambda () (print "Usage: " (car (argv)) " [OPTIONS...] [FILE]") (newline) (print (args:usage options)) (print "Report bugs to acdw@acdw.net."))) (exit exit-code)) (define (main args) (receive (options operands) (args:parse args opts) (let ((to (alist-ref 'to options)) (template (alist-ref 'template options))) (cond ((not to)) ; default: gemini ((equal? to "html") (import (jimmy html))) ((file-exists? to) (load to)) (else (error "File does not exist" to))) (print (apply jimmy (list (car operands) template)))))) (cond-expand (compiling (main (command-line-arguments))) (else))