aboutsummaryrefslogtreecommitdiff
path: root/lib/oneliner.lisp
diff options
context:
space:
mode:
authorColin Okay <okay@toyful.space>2022-03-13 14:21:33 -0500
committerColin Okay <okay@toyful.space>2022-03-13 14:21:33 -0500
commit7bcf634c789c00a95237ad74e5f923a4214020c8 (patch)
tree54274f67fc806b4fd57e8831ab11d4ccf4d5f371 /lib/oneliner.lisp
parent7ae6cbff1875ea271fa1724d6e53bc3d3d48dd26 (diff)
can make, run, and publish drafts
Diffstat (limited to 'lib/oneliner.lisp')
-rw-r--r--lib/oneliner.lisp15
1 files changed, 15 insertions, 0 deletions
diff --git a/lib/oneliner.lisp b/lib/oneliner.lisp
index 4828b2d..668a82c 100644
--- a/lib/oneliner.lisp
+++ b/lib/oneliner.lisp
@@ -94,3 +94,18 @@
(string-trim '(#\space)
(alexandria-2:subseq* (oneliner-brief ol) x (+ x *term-width*)))))
(format t "~%~a~%~%" (oneliner-oneliner ol))))
+
+;;;; json serialization
+
+(defun oneliner-to-json-body (ol)
+ "Takes a oneliner structure and produces some json suitable for
+sending to the server. ID and some other fields are omitted."
+ (jonathan:to-json
+ (list :oneliner (oneliner-oneliner ol)
+ :tags (oneliner-tags ol)
+ :brief (oneliner-brief ol)
+ :name (if (plusp (length (oneliner-name ol)))
+ (oneliner-name ol)
+ :null)
+ :explanation (oneliner-explanation ol)
+ :runstyle (oneliner-runstyle ol))))