aboutsummaryrefslogtreecommitdiff
path: root/lib/client.lisp
diff options
context:
space:
mode:
Diffstat (limited to 'lib/client.lisp')
-rw-r--r--lib/client.lisp22
1 files changed, 15 insertions, 7 deletions
diff --git a/lib/client.lisp b/lib/client.lisp
index 2753329..7ee9ebc 100644
--- a/lib/client.lisp
+++ b/lib/client.lisp
@@ -21,7 +21,7 @@
;; WITH-LOCAL-STATE form. If you are hacking in the REPL, make sure
;; to wrap function calls appropriately.
-;;; GETTING ONELINERS
+;;; GETTING ONELINERS & Displaying oneliners
(defun search-for-oneliners (terms limit &optional not-flagged-p all-flagged-p newestp)
(assert (loop for term in terms never (find #\, term)) () "Search terms may not contain commas.")
@@ -65,6 +65,13 @@ running the body. If such a oneliner can be found."
(api:get--oneliners-all-flagged))))
(cache-and-print-search-response response)))
+(defun print-item-explanation (name-or-number)
+ (when-oneliner (ol name-or-number)
+ (print-oneliner-result-for-user ol)
+ (when (oneliner-explanation ol)
+ (princ #\newline)
+ (princ (oneliner-explanation ol)))))
+
;;; RUNNING ONELINERS
(defvar *ol-output-timeout* 1)
@@ -77,8 +84,8 @@ running the body. If such a oneliner can be found."
(defun bind-vars-and-run-oneliner (ol args &optional force-clip)
(let* ((oneliner (oneliner-oneliner ol))
(runstyle (oneliner-runstyle ol))
- (pos-args (collect-positional-arguments oneliner))
- (named-args (collect-named-arguments oneliner)))
+ (pos-args (get-positional-arguments oneliner))
+ (named-args (get-named-arguments oneliner)))
(when (or (not (oneliner-isflagged ol))
(y-or-n-p "This oneliner is flagged. Are you sure you want to run it?"))
;; substitute positional args
@@ -183,7 +190,7 @@ running the body. If such a oneliner can be found."
:retry-text "Too long. Must be <= 72 characters: "
:prefill (oneliner-brief ol)))
(init-tags
- (tags-from-oneliner oneliner-string))
+ (parse-oneliner-tags oneliner-string))
(tags
(progn
(format t "Tags include: ~{~a ~}~%" init-tags)
@@ -205,7 +212,7 @@ running the body. If such a oneliner can be found."
(when (y-or-n-p "Provide an explanation?")
(string-from-editor (oneliner-explanation ol)))))
(let ((new-item
- (list :oneliner oneliner
+ (list :oneliner oneliner-string
:tags tags
:brief brief
:name (if (plusp (length name)) name :null)
@@ -215,7 +222,7 @@ running the body. If such a oneliner can be found."
(:body (jonathan:to-json new-item)
:content-type "application/json")
(api:patch--oneliner-entry-edit (oneliner-id ol) :token (api-token))
- (update-cached-item new-item)
+ (merge-oneliners (list new-item)) ;;TODO: this is broken, wait for API update.
(format t "OK~%"))))))
@@ -283,7 +290,7 @@ running the body. If such a oneliner can be found."
(:host (host)
:body (jonathan:to-json (list :signature new-sig))
:content-type "application/json")
- (api:put--contributor-who-signature (contributor-handle) :token (api-token))
+ (api:put--contributor-who-signature (handle) :token (api-token))
(format t "Your signature was changed.~%"))))
@@ -344,3 +351,4 @@ change their signature."
(getf contributor :handle)
(getf contributor :signature)))
+