about summary refs log tree commit diff stats
path: root/bin
diff options
context:
space:
mode:
authorCase Duckworth2024-06-05 09:21:25 -0500
committerCase Duckworth2024-06-05 09:21:25 -0500
commit423ac382f9e73bf1ca7fc6b400f98db087cd7d22 (patch)
tree1992e3dc7e71cd40eb7cdbc0b6d0c3cdf82c4332 /bin
parentUpdate README, add COPYING (diff)
downloadjimmy-423ac382f9e73bf1ca7fc6b400f98db087cd7d22.tar.gz
jimmy-423ac382f9e73bf1ca7fc6b400f98db087cd7d22.zip
Write executable
This involved moving `src' to `lib' and making `bin'.
`bin' holds the program, which only imports `jimmy.main' from lib.
Diffstat (limited to 'bin')
-rw-r--r--bin/jimmy.scm48
1 files changed, 48 insertions, 0 deletions
diff --git a/bin/jimmy.scm b/bin/jimmy.scm new file mode 100644 index 0000000..17e12ba --- /dev/null +++ b/bin/jimmy.scm
@@ -0,0 +1,48 @@
1;;; (jimmy main) --- the program
2
3(import (chicken file)
4 (chicken port)
5 (chicken process-context)
6 (jimmy main)
7 args)
8
9(define opts
10 (list (args:make-option (t to) (required: "FORMAT")
11 (string-append "Translate input to FORMAT."
12 " One of `gemini', `html', or"
13 " a filename."))
14 (args:make-option (n no-extensions) #:none
15 "Don't use gemtext extensions.")
16 (args:make-option (T template) (required: "TEMPLATE")
17 "Wrap the generated text in TEMPLATE.")
18 (args:make-option (h help) #:none "Display this text"
19 (usage 0))))
20
21(define (usage #!optional (exit-code 1))
22 (with-output-to-port (current-error-port)
23 (lambda ()
24 (print "Usage: " (car (argv)) " [OPTIONS...] [FILE]")
25 (newline)
26 (print (args:usage options))
27 (print "Report bugs to acdw@acdw.net.")))
28 (exit exit-code))
29
30(define (main args)
31 (receive (options operands) (args:parse args opts)
32 (let ((to (alist-ref 'to options))
33 (template (alist-ref 'template options)))
34
35 (cond
36 ((not to)) ; default: gemini
37 ((equal? to "html")
38 (import (jimmy html)))
39 ((file-exists? to)
40 (load to))
41 (else (error "File does not exist" to)))
42
43 (print (apply jimmy (list (car operands) template))))))
44
45(cond-expand
46 (compiling
47 (main (command-line-arguments)))
48 (else))