diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/lib.lisp | 27 |
1 files changed, 21 insertions, 6 deletions
diff --git a/src/lib.lisp b/src/lib.lisp index 2f25ac7..9253484 100644 --- a/src/lib.lisp +++ b/src/lib.lisp @@ -166,10 +166,25 @@ the directories that appear in the value of that variable." (format t "Could not find the oneliner specified by ~a~%" ,nvar))))) (defun print-item-explanation (number &optional idp) - (with-cached-result (ol number idp) - (when (getf ol :explanation) - (princ #\newline) - (princ (getf ol :explanation))))) + (let ((found nil)) + (with-cached-result (ol number idp) + (setf found t) + (when (getf ol :explanation) + (princ #\newline) + (princ (getf ol :explanation)))) + (when (and idp (not found)) + (format t "Trying to fetch oneliner with id ~a from the wiki.~%" number) + (ensure-config) + (a:if-let ((ol + (api:request-with (:host (host)) + (jonathan:parse + (api::get--oneliner-entry number))))) + (progn + (when (getf ol :explanation) + (princ #\newline) + (princ (getf ol :explanation))) + (merge-into-cache (list ol))) + (format t "Still couldn't find it. Are you connected?"))))) ;;; API REQUEST FUNCTIONS @@ -256,7 +271,7 @@ the directories that appear in the value of that variable." (setf found t) (bind-vars-and-run-oneliner ol args force-clip)) (when (and by-id (not found)) - (format t "Trying to fetch that oneliner with id ~a from the wiki.~%" item-number) + (format t "Trying to fetch oneliner with id ~a from the wiki.~%" item-number) (ensure-config) (a:if-let ((ol (api:request-with (:host (host)) @@ -264,7 +279,7 @@ the directories that appear in the value of that variable." (api::get--oneliner-entry item-number))))) (progn (bind-vars-and-run-oneliner ol args force-clip) (merge-into-cache (list ol))) - (format t "Still couldn't find it. Is something wrong?"))))) + (format t "Still couldn't find it. Are you connected?"))))) (defun valid-oneliner-string-p (string) (and (not (find #\newline string)) |