aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--oneliners.cli.asd2
-rw-r--r--src/lib.lisp27
2 files changed, 22 insertions, 7 deletions
diff --git a/oneliners.cli.asd b/oneliners.cli.asd
index 19cdb69..7b298cb 100644
--- a/oneliners.cli.asd
+++ b/oneliners.cli.asd
@@ -1,5 +1,5 @@
(defsystem "oneliners.cli"
- :version "0.4.2"
+ :version "0.4.3"
:author "Colin Okay"
:license "AGPLv3"
:depends-on ("trivial-clipboard"
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))