From 50de25d9728ed7da8147142e659857bbfbc754d1 Mon Sep 17 00:00:00 2001 From: Colin Okay Date: Mon, 28 Feb 2022 15:23:55 -0600 Subject: edits update local cache. revoke renamed logout --- src/lib.lisp | 45 ++++++++++++++++++++++++++++----------------- 1 file changed, 28 insertions(+), 17 deletions(-) (limited to 'src') diff --git a/src/lib.lisp b/src/lib.lisp index e81c7af..7df571b 100644 --- a/src/lib.lisp +++ b/src/lib.lisp @@ -340,17 +340,20 @@ the directories that appear in the value of that variable." (explanation (when (y-or-n-p "Provide an explanation?") (string-from-editor (getf ol :explanation))))) - (api:request-with - (:host (host) - :body (jonathan:to-json - (list :oneliner oneliner - :tags tags - :brief brief - :explanation explanation - :runstyle runstyle)) - :content-type "application/json") - (api:patch--oneliner-entry-edit (getf ol :id) :token (api-token)) - (format t "OK~%"))))) + (let ((new-item + (list :oneliner oneliner + :tags tags + :brief brief + :explanation explanation + :runstyle runstyle))) + (api:request-with + (:host (host) + :body (jonathan:to-json + new-item) + :content-type "application/json") + (api:patch--oneliner-entry-edit (getf ol :id) :token (api-token)) + (update-history-item n new-item) + (format t "OK~%")))))) (defun request-invite-code () (ensure-config) @@ -370,7 +373,7 @@ the directories that appear in the value of that variable." :content-type "application/json") (api:post--access)))) (setf (api-token) (getf response :token) - (contributor-handle) handle) + (contributor-handle) user) (write-config-to-disk) (format t "Access token written to ~a~%You may now make contributions to the wiki!.~%" (config-file)))) @@ -421,6 +424,14 @@ the directories that appear in the value of that variable." (:host (host)) (api:delete--access-access (api-token) :token (api-token)))) +(defun update-history-item (n item) + (when (uiop:file-exists-p (last-search-file)) + (let* ((results (with-open-file (input (last-search-file)) (read input))) + (ol (nth (1- n) results))) + (when ol + (setf (nth (1- n) results) (append item ol)) + (cache-search-results-to-last-search-file results))))) + (defun cache-search-results-to-last-search-file (results) (with-open-file (output (last-search-file) :direction :output :if-exists :supersede) (print results output))) @@ -518,11 +529,11 @@ printed to OUTPUT-STREAM. " (shell-output (uiop:process-info-output shell))) (write-line command shell-input) (finish-output shell-input) - (if (and await-output-p - (wait-until (:timeout await-output-p :poll-every 0.005) - (listen shell-output))) + (if (and await-output-p + (plusp await-output-p) + (wait-until (:timeout await-output-p :poll-every 0.005) + (listen shell-output))) (loop while (listen shell-output) do (princ (read-line shell-output) output-stream) - (terpri output-stream)) - (format t "Timed out waiting for output. Try a longer --timeout.~%"))))) + (terpri output-stream)))))) -- cgit v1.2.3