aboutsummaryrefslogtreecommitdiff
path: root/lib/client.lisp
diff options
context:
space:
mode:
authorColin Okay <okay@toyful.space>2022-03-13 11:57:06 -0500
committerColin Okay <okay@toyful.space>2022-03-13 11:57:06 -0500
commit07183b5bbb4d2e65514e3ec3e7cdf7e421f97749 (patch)
treea5a672d8bc1b58a46dae98be663f865b1b3b9427 /lib/client.lisp
parent80bf9816c6e35bf7ffcc1e4349d5abf056c4df7f (diff)
added intial drafting code to new
Diffstat (limited to 'lib/client.lisp')
-rw-r--r--lib/client.lisp38
1 files changed, 31 insertions, 7 deletions
diff --git a/lib/client.lisp b/lib/client.lisp
index fe29932..8d40fd5 100644
--- a/lib/client.lisp
+++ b/lib/client.lisp
@@ -131,8 +131,18 @@ running the body. If such a oneliner can be found."
(prompt "Name (leave blank for none): "
:expect 'valid-oneliner-name-p
:retry-text "Must begin with a letter contain only letters, numbers, - and _.")))
+
+ (draft-name
+ (unless (y-or-n-p "Upload immediately instead of keeping a draft?")
+ (if (plusp (length name))
+ name
+ (prompt "No name was provided, name this draft: "
+ :expect 'valid-oneliner-name-p
+ :retry-text "Must begin with a letter contain only letters, numbers, - and _."))))
+
(init-tags
(parse-oneliner-tags oneliner-string))
+
(brief
(prompt "Brief Description: "
:expect 'valid-brief-description-p
@@ -153,17 +163,31 @@ running the body. If such a oneliner can be found."
(when (y-or-n-p "Provide an explanation?")
(string-from-editor
(format nil "~a~%~%" oneliner-string)))))
- (api:request-with
- (:body (jonathan:to-json
- (list :oneliner oneliner-string
- :name (if (plusp (length name)) name :null)
+ (if draft-name
+ ;; if this is a draft, save it to disk.
+ (progn
+ (put-draft draft-name
+ (make-oneliner
+ :oneliner oneliner-string
+ :name name
:tags tags
:brief brief
:explanation explanation
:runstyle runstyle))
- :content-type "application/json")
- (api:post--oneliner :token (api-token)) ;TODO: update api to return the instance created.
- (format t "Added~%"))))
+ (format t "Saved draft ~a~%" draft-name))
+ ;; otherwise, format the oneliner as json and make a request
+ ;; to create a new oneliner in the wiki
+ (api:request-with
+ (:body (jonathan:to-json
+ (list :oneliner oneliner-string
+ :name (if (plusp (length name)) name :null)
+ :tags tags
+ :brief brief
+ :explanation explanation
+ :runstyle runstyle))
+ :content-type "application/json")
+ (api:post--oneliner :token (api-token)) ;TODO: update api to return the instance created.
+ (format t "Added Oneliner~%")))))
;;; EDITING ONELINERS