From 2c49e526105cd04d4b76bc204929ee8b8a9f6c6b Mon Sep 17 00:00:00 2001 From: Colin Okay Date: Fri, 18 Feb 2022 21:02:06 -0600 Subject: adding adding --- src/lib.lisp | 47 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) (limited to 'src/lib.lisp') 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 -- cgit v1.2.3