summaryrefslogtreecommitdiff
path: root/cook/cli.scm
blob: f912a899e3174a21af68b9daa08815fc4a0c0cba (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
(import (cook parse-internals)
        (cook debug)
        (cook html)
        (chibi)
        (chibi app)
        (chibi config)
        (chibi io)
        (chibi test))

(define (cook cfg spec . args)
  (display "called cook with: ")
  (display args)
  (newline))

(define (read-cook cfg spec recipe-file)
  (let ((recipe (parse-cook (file->string recipe-file))))
    (display (cook->list recipe))))

(define (html-cook cfg spec recipe-file)
  (let ((recipe (parse-cook (file->string recipe-file))))
    (display (recipe->html recipe))
    (newline)))

(run-application
  `(cook
    "Cooklang recipe tool"
    (@
      (help boolean (#\h ) "show this help"))
    (or
      (help "Show this help" () (,app-help-command))
      (read "Read recipe in the terminal" () (,read-cook recipe))
      (html "Display recipe in HTML format" () (,html-cook recipe)))
    (,cook files ...))
  (command-line))