-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathtemplate.rkt
53 lines (42 loc) · 1.67 KB
/
template.rkt
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
53
#lang racket
(require racket/cmdline)
(require "stealc.rkt")
(require "examples/atomicswap.rkt")
(require "examples/feedynamic.rkt")
(require "examples/split.rkt")
(require "examples/feeproxy.rkt")
(require "examples/periodicpayment.rkt")
(require "examples/limitorder.rkt")
(define dirname (make-parameter ""))
(define output-dir
(command-line
#:once-each
[("-d" "--directory") n "Output directory" (dirname n)]))
(define log-exn (lambda (exn) (printf "drop exception ~a~n" exn)))
(with-handlers ([exn:fail:filesystem:exists? log-exn])
(make-directory (dirname)))
(define (comment-out str)
(string-join (map (lambda (s) (if (string=? s "") "//" (string-append "// " s)))
(string-split str "\n"))
"\n"))
(define templates
`(["atomic-swap" ,atomicswap ,atomicswap-doc]
["dynamic-fee" ,feedynamic ,feedynamic-doc]
;; ["periodic-payment" ,periodicpayment]
["periodic-payment-escrow" ,periodicpayment-escrow ,periodicpayment-escrow-doc]
["split" ,split ,split-doc]
["delegate-key-registration" ,feeproxykeyreg ,feeproxykeyreg-doc]
["limit-order" ,limitorder ,limitorder-doc]))
;; ["limit-order-fill" ,limitorder-fill]))
(define template-ext ".teal.tmpl")
(for-each (lambda (x)
(let ([fname (first x)]
[template-data (second x)]
[template-doc (third x)])
(call-with-output-file
(build-path (dirname) (string-append fname template-ext))
#:exists 'truncate
(lambda (out)
(displayln (comment-out template-doc) out)
(display (stealc template-data) out)))))
templates)