-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgenerate-http-status.lisp
More file actions
40 lines (38 loc) · 1.94 KB
/
generate-http-status.lisp
File metadata and controls
40 lines (38 loc) · 1.94 KB
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
(ql:quickload '(:str :cl-csv))
(with-open-file (output (merge-pathnames "./http/package.lisp" (uiop:getcwd)) :direction :output :if-exists :supersede :if-does-not-exist :create)
(with-open-file (file (merge-pathnames "data/http_statuses.csv" (uiop:getcwd)))
(let ((header '(defpackage #:wst.http
(:use #:cl))))
(write header :stream output))
(write-char #\NEWLINE output)
(write-char #\NEWLINE output)
(let ((inpkg '(in-package :wst.http)))
(write inpkg :stream output))
(write-char #\NEWLINE output)
(write-char #\NEWLINE output)
(map nil (lambda (row)
(destructuring-bind (code message doc link)
row
(let* ((var-text (str:concat "http-status-" code))
(var-name (intern (str:upcase var-text)))
(code-var-name (intern (str:upcase (str:concat "+" var-text "+"))))
(var-code `(defvar ,code-var-name
,(parse-integer code)))
(var `(defvar ,var-name
',(list (parse-integer code)
(string message)
(string doc)
(string link)))))
(write var-code :stream output)
(write-char #\NEWLINE output)
(write-char #\NEWLINE output)
(write `(export ',code-var-name) :stream output)
(write-char #\NEWLINE output)
(write-char #\NEWLINE output)
(write var :stream output)
(write-char #\NEWLINE output)
(write-char #\NEWLINE output)
(write `(export ',var-name) :stream output)
(write-char #\NEWLINE output)
(write-char #\NEWLINE output))))
(cdr (cl-csv:read-csv file)))))