diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/lib.lisp | 47 |
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 |