diff options
-rw-r--r-- | build-app.lisp | 12 | ||||
-rw-r--r-- | src/lib.lisp | 45 |
2 files changed, 37 insertions, 20 deletions
diff --git a/build-app.lisp b/build-app.lisp index 7da683b..c481352 100644 --- a/build-app.lisp +++ b/build-app.lisp @@ -84,8 +84,10 @@ Topics: wiki, access, invites")) (group (:header "Access" :hidden t) (flag :long-name "login" :description "Attempt to login to your contributor account. ARGS are interpreted as USERNAME PASSWORD.") - (flag :long-name "revoke" - :description "Revoke your own access token.")) + (flag :long-name "logout" + :description "Revoke your own access token.") + (flag :long-name "change-password" + :description "Change your password. ARGS are interpreted as CURRENTPW NEWPW NEWPWAGAIN")) (group (:header "Invites" :hidden t) (flag :long-name "invite" :description "Request an invite token to send to a friend.") @@ -128,10 +130,14 @@ than the users." (destructuring-bind (user pass) arguments (cli::login user pass))) + ((getopt :long-name "change-password") + (destructuring-bind (current new repeated) arguments + (cli::change-pw current new repeated))) + ((getopt :long-name "invite") (cli::request-invite-code)) - ((getopt :long-name "revoke") + ((getopt :long-name "logout") (cli::revoke-access)) ((getopt :long-name "add") 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)))))) |