about summary refs log tree commit diff stats
path: root/wikme.scm
diff options
context:
space:
mode:
authorCase Duckworth2023-03-29 23:33:04 -0500
committerCase Duckworth2023-03-29 23:33:04 -0500
commit920b1d5df49d0bf16084150ac0994807f9c66447 (patch)
treeae0aebe7a8e3274cfee7915b3596b5a78b9d3360 /wikme.scm
parentBegin on executable (diff)
downloadwikme-920b1d5df49d0bf16084150ac0994807f9c66447.tar.gz
wikme-920b1d5df49d0bf16084150ac0994807f9c66447.zip
Ready for testing
Diffstat (limited to 'wikme.scm')
-rw-r--r--wikme.scm45
1 files changed, 29 insertions, 16 deletions
diff --git a/wikme.scm b/wikme.scm index 7f992a3..74d672f 100644 --- a/wikme.scm +++ b/wikme.scm
@@ -1,6 +1,7 @@
1;;; wikme.scm --- build a wiki from a folder of markdown --- executable 1;;; wikme.scm --- build a wiki from a folder of markdown --- executable
2 2
3(import (args) 3(import (args)
4 (chicken pathname)
4 (chicken process-context) 5 (chicken process-context)
5 (chicken port)) 6 (chicken port))
6 7
@@ -8,32 +9,44 @@
8 9
9 10
10 11
11 ;; (make-wiki base-url ; base URL for links 12(define +opts+
12 ;; origin-dir ; origin directory 13 (list (args:make-option
13 ;; destination-dir ; destination directory 14 (u base-url) (optional: "URL")
14 ;; page-template ; template for pages 15 "Base URL for the generated Wiki.")
15 ;; file-transformers ; list of filename transformers 16 (args:make-option
16 ;; transformers ; list of source transformer functions 17 (s source) (optional: "DIRECTORY")
17 ;; pages ; list of <page>s 18 "Directory containing source files (default: PWD).")
18 ;; ) 19 (args:make-option
19 20 (o out) (optional: "DIRECTORY")
20 21 "Directory in which to place rendered files (default: PWD/out).")
21(define options 22 (args:make-option
22 (list (args:make-option ))) 23 (t template) (optional: "FILE")
24 "Template file for wiki pages (default: PWD/template.html).")))
23 25
24 26
25 27
26(define (usage) 28(define (usage)
27 (with-output-to-port (current-error-port) 29 (with-output-to-port (current-error-port)
28 (lambda () 30 (lambda ()
29 (print "Usage: " (car (argv)) " [options...] [directory]") 31 (print "Usage: " (car (argv)) " [options...]")
30 (newline) 32 (newline)
31 (print (args:usage options)))) 33 (print (args:usage +opts+))))
32 (exit 1)) 34 (exit 1))
33 35
34(define (main args) 36(define (main args)
35 (receive (options operands) 37 (receive (options operands)
36 (args:parse args options) 38 (args:parse args +opts+)
37 #f)) 39 (render-wiki
40 (directory->wiki
41 (or (alist-ref 'source options)
42 (current-directory))
43 #:base-url (or (alist-ref 'base-url options)
44 "https://www.example.com")
45 #:destination-directory (or (alist-ref 'out options)
46 (make-pathname
47 (current-directory) "out"))
48 #:page-template (or (alist-ref 'template options)
49 (make-pathname
50 (current-directory "template.html")))))))
38 51
39(main (command-line-arguments)) 52(main (command-line-arguments))