aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/lib.lisp21
1 files changed, 15 insertions, 6 deletions
diff --git a/src/lib.lisp b/src/lib.lisp
index 47e12f8..30c953d 100644
--- a/src/lib.lisp
+++ b/src/lib.lisp
@@ -86,7 +86,7 @@
(merge-pathnames ".config/oneliners.config" (user-homedir-pathname)))
(defun cached-oneliners-file ()
- (merge-pathnames ".cached_oneliners" (user-homedir-pathname)))
+ (merge-pathnames ".cache/cached_oneliners" (user-homedir-pathname)))
(defun wipe-cache ()
(uiop:delete-file-if-exists (cached-oneliners-file)))
@@ -102,6 +102,7 @@
for id = (getf old :id)
unless (find id new-ols :key (lambda (x) (getf x :id)))
collect old))))
+ (ensure-directories-exist (cached-oneliners-file))
(with-open-file (output (cached-oneliners-file) :direction :output :if-exists :supersede)
(print updated output))))
@@ -194,9 +195,15 @@ and, failing that, try to fetch from configured server."
(with-oneliner (ol name-or-number)
(set-term-width)
(print-oneliner-result-for-user ol)
- (when (getf ol :explanation)
- (princ #\newline)
- (princ (getf ol :explanation)))))
+ (a:when-let (explanation (getf ol :explanation))
+ (format t "EXPLANATION:~%~%")
+ (princ
+ (string-trim
+ '(#\newline #\space #\tab)
+ (if (str:starts-with? (getf ol :oneliner) explanation)
+ (subseq explanation (length (getf ol :oneliner)))
+ explanation)))
+ (terpri))))
;;; API REQUEST FUNCTIONS
@@ -563,7 +570,7 @@ and, failing that, try to fetch from configured server."
(api:get--oneliners-all-flagged))))
(cache-and-print-search-response response))))
-(defun search-for-oneliners (terms limit not-flagged-p)
+(defun search-for-oneliners (terms limit not-flagged-p all-flagged-p newestp)
(assert (loop for term in terms never (find #\, term) ))
(set-term-width)
(ensure-config)
@@ -572,7 +579,9 @@ and, failing that, try to fetch from configured server."
(:host (host))
(api:get--oneliners :tags (str:join "," terms)
:limit limit
- :notflagged (if not-flagged-p "true" "false")))))
+ :notflagged (if not-flagged-p "true" "false")
+ :newest (if newestp "true" "false")
+ :onlyflagged (if all-flagged-p "true" "false")))))
(cache-and-print-search-response response)))
;;; RUNNING THINGS IN THE SHELL.