aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorColin Okay <okay@toyful.space>2022-02-18 21:02:06 -0600
committerColin Okay <okay@toyful.space>2022-02-18 21:02:06 -0600
commit2c49e526105cd04d4b76bc204929ee8b8a9f6c6b (patch)
treef8d5c9ca9de3b7298b4384ca54c746e4a618a128 /src
parentc2475ad2a120f67a2dd373d1e720e4dac77d1d7e (diff)
adding adding
Diffstat (limited to 'src')
-rw-r--r--src/lib.lisp47
1 files changed, 47 insertions, 0 deletions
diff --git a/src/lib.lisp b/src/lib.lisp
index 0ae2b8b..ec65d13 100644
--- a/src/lib.lisp
+++ b/src/lib.lisp
@@ -63,8 +63,55 @@
(when (uiop:file-exists-p (last-search-file))
(nth n (uiop:read-file-form (last-search-file)))))
+(defun command-on-system (cmd)
+ )
+
+(defun tags-from-oneliner (oneliner)
+ (loop for cmd? in (ppcre:split " +" oneliner)
+ when (command-on-system cmd?)
+ collect cmd?))
+
+(defun prompt (prompt &key (out-stream *standard-output*) (in-stream *standard-input*))
+ (princ prompt out-stream)
+ (read-line in-stream))
+
;;; API REQUEST FUNCTIONS
+;; (defun flag-item (item-number)
+;; (ensure-config)
+;; (api:request-with
+;; (:host (host))
+;; (a:if-let ((token (api-token))
+;; (oneliner (history item-number)))
+;; (api:patch--flag-oneliner (getf oneliner :id) :token token))))
+
+(defun add-new-oneliner ()
+ (ensure-config)
+ (assert (api-token) () "Cannot add a oneliner without an api token.")
+ (let* ((oneliner
+ (prompt "Oneliner: "))
+ (init-tags
+ (tags-from-oneliner oneliner))
+ (brief
+ (prompt "Brief Description: "))
+ (tags
+ (when (y-or-n-p "Add tags in addition to: ~{~a ~}?" init-tags)
+ (ppcre:split " +" (prompt "(e.g. foo bar goo): "))))
+ (explaination
+ (when (y-or-n-p "Provide an explaination?")
+ (prompt "Go head: "))))
+ (format t "Adding a new oneliner.~%")
+
+ ;; (api:request-with
+ ;; (:host (host)
+ ;; :body (jonathan:to-json
+ ;; (list :oneliners oneliner
+ ;; :brief brief
+ ;; :tags )))
+ ;; (api:post--add-oneliner :token (api-token)))
+
+ (format t "Added~%")))
+
(defun request-invite-code ()
(ensure-config)
(api:request-with