about summary refs log tree commit diff stats
path: root/wikme.scm
blob: ac7111c0cbeff024e1efa3dfabc16d102ab240e9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
;;; wikme.scm --- build a wiki from a folder of markdown --- executable

(import (args)
        (chicken pathname)
        (chicken process-context)
        (chicken port))

(include "src/wikme")



(define +opts+
  (list (args:make-option
         (u base-url) (optional: "URL")
         "Base URL for the generated Wiki.")
        (args:make-option
         (s source) (optional: "DIRECTORY")
         "Directory containing source files (default: PWD).")
        (args:make-option
         (o out) (optional: "DIRECTORY")
         "Directory in which to place rendered files (default: PWD/out).")
        (args:make-option
         (t template) (optional: "FILE")
         "Template file for wiki pages (default: PWD/template.html).")))



(define (usage)
  (with-output-to-port (current-error-port)
    (lambda ()
      (print "Usage: " (car (argv)) " [options...]")
      (newline)
      (print (args:usage +opts+))))
  (exit 1))

(define (main args)
  (receive (options operands)
      (args:parse args +opts+)
    (render-wiki
     (directory->wiki
      (or (alist-ref 'source options)
          (current-directory))
      #:base-url (or (alist-ref 'base-url options)
                     "https://www.example.com")
      #:destination-directory (or (alist-ref 'out options)
                                  (make-pathname
                                   (current-directory) "out"))
      #:page-template (or (alist-ref 'template options)
                          (make-pathname
                           (current-directory) "template.html"))))))

(main (command-line-arguments))