diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/lib.lisp | 23 |
1 files changed, 17 insertions, 6 deletions
diff --git a/src/lib.lisp b/src/lib.lisp index b21272a..b8c7343 100644 --- a/src/lib.lisp +++ b/src/lib.lisp @@ -12,9 +12,10 @@ (defvar *config* nil "A configuration plist") -(defun make-config (&key host api-token) +(defun make-config (&key host api-token editor) (append (when host (list :host host)) - (when api-token (list :api-token api-token)))) + (when api-token (list :api-token api-token)) + (when editor (list :editor editor)))) (defun valid-config-p (config) (and (listp config) @@ -51,6 +52,11 @@ (defun (setf api-token) (newval) (setf (getf *config* :api-token) newval)) +(defun make-temp-file-name () + (merge-pathnames (format nil "~a" (gensym "oneliners")) (uiop:temporary-directory))) + +(defun string-from-editor () + (magic-ed:magic-ed make-temp-file-name :eval nil :output :string)) (defun config-file () (merge-pathnames ".config/oneliners.config" (user-homedir-pathname))) @@ -102,12 +108,17 @@ the directories that appear in the value of that variable." (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): ")))) + (append init-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.~%") + (string-from-editor)))) + (format t "Adding a new oneliner.~%~s~%" + (list :oneliners oneliner + :tags tags + :brief brief + :explanation explaination)) ;; (api:request-with ;; (:host (host) |