aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--build-app.lisp20
-rw-r--r--oneliners.api-client.lisp168
-rw-r--r--oneliners.cli.asd2
-rw-r--r--src/lib.lisp21
4 files changed, 126 insertions, 85 deletions
diff --git a/build-app.lisp b/build-app.lisp
index dd70322..b50635f 100644
--- a/build-app.lisp
+++ b/build-app.lisp
@@ -102,11 +102,11 @@ export EDITOR=/usr/bin/zile
:description "The maximum number of results to return."
:typespec 'integer)
(flag :long-name "all-flagged"
- :description "Return flagged oneliners.")
+ :description "Request that only flagged oneliners are returned. Without any ARGUMENTS, simply returns all flagged oneliners.")
(flag :long-name "not-flagged"
- :description "Request that no flagged oneliners are returned.")
+ :description "Request that no flagged oneliners are returned with the search results. Does nothing without ARGUMENTS")
(flag :long-name "newest"
- :description "Return newest oneliners."))
+ :description "Return newest oneliners that match. Without any ARGUMENTS, simply returns the newest oneliners."))
(text :contents " ")
(group (:header "EXECUTION OPTIONS")
(text :contents "Several options override the default interpretation of ARGUMENTS.")
@@ -119,7 +119,7 @@ export EDITOR=/usr/bin/zile
:description "Like --run, but puts the oneliner into the clipboard."))
(text :contents " ")
(group (:header "OTHER OPTIONS")
- (flag :long-name "view"
+ (flag :long-name "show"
:description "View all information for the oneliner given by NAME or ID")
(lispobj :long-name "timeout"
:argument-type :optional
@@ -238,12 +238,10 @@ than the users."
((getopt :long-name "add")
(cli::add-new-oneliner))
- ((getopt :long-name "all-flagged")
- (format t "WARNING: --all-flagged is likely to soon change its behavior~%.")
+ ((and (null arguments) (getopt :long-name "all-flagged"))
(cli::all-flagged-oneliners (getopt :long-name "limit")))
- ((getopt :long-name "newest")
- (format t "WARNING: --newest is likely to soon change its behavior~%")
+ ((and (null arguments) (getopt :long-name "newest"))
(cli::newest-oneliners (getopt :long-name "limit")))
((getopt :long-name "clear-cache")
@@ -262,7 +260,7 @@ than the users."
(cli::unlock-item id-or-name ))
((getopt :long-name "edit")
(cli::edit-item id-or-name ))
- ((getopt :long-name "view")
+ ((getopt :long-name "show")
(cli::print-item-explanation id-or-name))
((getopt :long-name "clip")
(cli::run-item id-or-name args
@@ -274,7 +272,9 @@ than the users."
(t
(cli::search-for-oneliners arguments
(getopt :long-name "limit")
- (getopt :long-name "not-flagged")))))
+ (getopt :long-name "not-flagged")
+ (getopt :long-name "all-flagged")
+ (getopt :long-name "newest")))))
(uiop:quit))
(t
(help)))
diff --git a/oneliners.api-client.lisp b/oneliners.api-client.lisp
index 5fc6f10..e135973 100644
--- a/oneliners.api-client.lisp
+++ b/oneliners.api-client.lisp
@@ -21,7 +21,8 @@
#:PUT--CONTRIBUTOR-WHO-SIGNATURE
#:PUT--CONTRIBUTOR-WHO-PASSWORD
#:PUT--CONTRIBUTOR-WHO-LOCKED
-#:GET--CONTRIBUTOR-WHO))
+#:GET--CONTRIBUTOR-WHO
+#:POST--SNAPSHOT))
(in-package :ONELINERS.API-CLIENT)
@@ -70,14 +71,14 @@ COOKIES should be an instance of CL-COOKIE:COOKIE-JAR. Defaults to
(dex:response-body ,http-error-var)))))))
-(DEFUN GET--ONELINERS (&KEY TAGS LIMIT NOTFLAGGED)
+(DEFUN GET--ONELINERS (&KEY TAGS LIMIT NOTFLAGGED NEWEST ONLYFLAGGED)
"A search endpoint returning a JSON encoded array of Oneliner
Entries. TAGS cannot be empty. Returns a [Search
Result](#search-result) object."
(LET ((LAZYBONES-CLIENT.SHARED::REQ-STRING
(APPLY #'CONCATENATE 'STRING LAZYBONES-CLIENT.SHARED:*HOST* "/api"
(FORMAT NIL "/oneliners")
- (WHEN (OR TAGS LIMIT NOTFLAGGED)
+ (WHEN (OR TAGS LIMIT NOTFLAGGED NEWEST ONLYFLAGGED)
(LIST "?"
(IF TAGS
(CONCATENATE 'STRING (SYMBOL-NAME 'TAGS) "="
@@ -90,10 +91,18 @@ Result](#search-result) object."
(IF NOTFLAGGED
(CONCATENATE 'STRING "&" (SYMBOL-NAME 'NOTFLAGGED)
"=" (FORMAT NIL "~a" NOTFLAGGED))
+ "")
+ (IF NEWEST
+ (CONCATENATE 'STRING "&" (SYMBOL-NAME 'NEWEST) "="
+ (FORMAT NIL "~a" NEWEST))
+ "")
+ (IF ONLYFLAGGED
+ (CONCATENATE 'STRING "&" (SYMBOL-NAME 'ONLYFLAGGED)
+ "=" (FORMAT NIL "~a" ONLYFLAGGED))
""))))))
(DEXADOR:GET LAZYBONES-CLIENT.SHARED::REQ-STRING :COOKIE-JAR
- LAZYBONES-CLIENT.SHARED:*COOKIES* :HEADERS
- LAZYBONES-CLIENT.SHARED:*HEADERS*)))
+ LAZYBONES-CLIENT.SHARED:*COOKIES* :HEADERS
+ LAZYBONES-CLIENT.SHARED:*HEADERS*)))
(DEFUN GET--ONELINERS-ALL-FLAGGED (&KEY LIMIT)
@@ -109,8 +118,8 @@ Result](#search-result) object."
(FORMAT NIL "~a" LIMIT))
""))))))
(DEXADOR:GET LAZYBONES-CLIENT.SHARED::REQ-STRING :COOKIE-JAR
- LAZYBONES-CLIENT.SHARED:*COOKIES* :HEADERS
- LAZYBONES-CLIENT.SHARED:*HEADERS*)))
+ LAZYBONES-CLIENT.SHARED:*COOKIES* :HEADERS
+ LAZYBONES-CLIENT.SHARED:*HEADERS*)))
(DEFUN GET--ONELINERS-NEWEST (&KEY LIMIT)
@@ -125,8 +134,8 @@ Result](#search-result) object."
(FORMAT NIL "~a" LIMIT))
""))))))
(DEXADOR:GET LAZYBONES-CLIENT.SHARED::REQ-STRING :COOKIE-JAR
- LAZYBONES-CLIENT.SHARED:*COOKIES* :HEADERS
- LAZYBONES-CLIENT.SHARED:*HEADERS*)))
+ LAZYBONES-CLIENT.SHARED:*COOKIES* :HEADERS
+ LAZYBONES-CLIENT.SHARED:*HEADERS*)))
(DEFUN PUT--ONELINER-ENTRY-FLAG (ENTRY &KEY TOKEN VALUE)
@@ -146,12 +155,12 @@ Result](#search-result) object."
""))))))
(IF LAZYBONES-CLIENT.SHARED:*BODY*
(DEXADOR:PUT LAZYBONES-CLIENT.SHARED::REQ-STRING :CONTENT
- LAZYBONES-CLIENT.SHARED:*BODY* :COOKIE-JAR
- LAZYBONES-CLIENT.SHARED:*COOKIES* :HEADERS
- LAZYBONES-CLIENT.SHARED:*HEADERS*)
+ LAZYBONES-CLIENT.SHARED:*BODY* :COOKIE-JAR
+ LAZYBONES-CLIENT.SHARED:*COOKIES* :HEADERS
+ LAZYBONES-CLIENT.SHARED:*HEADERS*)
(DEXADOR:PUT LAZYBONES-CLIENT.SHARED::REQ-STRING :COOKIE-JAR
- LAZYBONES-CLIENT.SHARED:*COOKIES* :HEADERS
- LAZYBONES-CLIENT.SHARED:*HEADERS*))))
+ LAZYBONES-CLIENT.SHARED:*COOKIES* :HEADERS
+ LAZYBONES-CLIENT.SHARED:*HEADERS*))))
(DEFUN GET--ONELINER-ENTRY (ENTRY)
@@ -160,8 +169,8 @@ Result](#search-result) object."
(APPLY #'CONCATENATE 'STRING LAZYBONES-CLIENT.SHARED:*HOST* "/api"
(FORMAT NIL "/oneliner/~a" ENTRY) NIL)))
(DEXADOR:GET LAZYBONES-CLIENT.SHARED::REQ-STRING :COOKIE-JAR
- LAZYBONES-CLIENT.SHARED:*COOKIES* :HEADERS
- LAZYBONES-CLIENT.SHARED:*HEADERS*)))
+ LAZYBONES-CLIENT.SHARED:*COOKIES* :HEADERS
+ LAZYBONES-CLIENT.SHARED:*HEADERS*)))
(DEFUN PATCH--ONELINER-ENTRY-EDIT (ENTRY &KEY TOKEN)
@@ -177,12 +186,12 @@ Result](#search-result) object."
""))))))
(IF LAZYBONES-CLIENT.SHARED:*BODY*
(DEXADOR:PATCH LAZYBONES-CLIENT.SHARED::REQ-STRING :CONTENT
- LAZYBONES-CLIENT.SHARED:*BODY* :COOKIE-JAR
- LAZYBONES-CLIENT.SHARED:*COOKIES* :HEADERS
- LAZYBONES-CLIENT.SHARED:*HEADERS*)
+ LAZYBONES-CLIENT.SHARED:*BODY* :COOKIE-JAR
+ LAZYBONES-CLIENT.SHARED:*COOKIES* :HEADERS
+ LAZYBONES-CLIENT.SHARED:*HEADERS*)
(DEXADOR:PATCH LAZYBONES-CLIENT.SHARED::REQ-STRING :COOKIE-JAR
- LAZYBONES-CLIENT.SHARED:*COOKIES* :HEADERS
- LAZYBONES-CLIENT.SHARED:*HEADERS*))))
+ LAZYBONES-CLIENT.SHARED:*COOKIES* :HEADERS
+ LAZYBONES-CLIENT.SHARED:*HEADERS*))))
(DEFUN PUT--ONELINER-ONELINER-LOCKED (ONELINER &KEY TOKEN VALUE)
@@ -202,12 +211,12 @@ Result](#search-result) object."
""))))))
(IF LAZYBONES-CLIENT.SHARED:*BODY*
(DEXADOR:PUT LAZYBONES-CLIENT.SHARED::REQ-STRING :CONTENT
- LAZYBONES-CLIENT.SHARED:*BODY* :COOKIE-JAR
- LAZYBONES-CLIENT.SHARED:*COOKIES* :HEADERS
- LAZYBONES-CLIENT.SHARED:*HEADERS*)
+ LAZYBONES-CLIENT.SHARED:*BODY* :COOKIE-JAR
+ LAZYBONES-CLIENT.SHARED:*COOKIES* :HEADERS
+ LAZYBONES-CLIENT.SHARED:*HEADERS*)
(DEXADOR:PUT LAZYBONES-CLIENT.SHARED::REQ-STRING :COOKIE-JAR
- LAZYBONES-CLIENT.SHARED:*COOKIES* :HEADERS
- LAZYBONES-CLIENT.SHARED:*HEADERS*))))
+ LAZYBONES-CLIENT.SHARED:*COOKIES* :HEADERS
+ LAZYBONES-CLIENT.SHARED:*HEADERS*))))
(DEFUN POST--ONELINER (&KEY TOKEN)
@@ -223,12 +232,12 @@ Result](#search-result) object."
""))))))
(IF LAZYBONES-CLIENT.SHARED:*BODY*
(DEXADOR:POST LAZYBONES-CLIENT.SHARED::REQ-STRING :CONTENT
- LAZYBONES-CLIENT.SHARED:*BODY* :COOKIE-JAR
- LAZYBONES-CLIENT.SHARED:*COOKIES* :HEADERS
- LAZYBONES-CLIENT.SHARED:*HEADERS*)
+ LAZYBONES-CLIENT.SHARED:*BODY* :COOKIE-JAR
+ LAZYBONES-CLIENT.SHARED:*COOKIES* :HEADERS
+ LAZYBONES-CLIENT.SHARED:*HEADERS*)
(DEXADOR:POST LAZYBONES-CLIENT.SHARED::REQ-STRING :COOKIE-JAR
- LAZYBONES-CLIENT.SHARED:*COOKIES* :HEADERS
- LAZYBONES-CLIENT.SHARED:*HEADERS*))))
+ LAZYBONES-CLIENT.SHARED:*COOKIES* :HEADERS
+ LAZYBONES-CLIENT.SHARED:*HEADERS*))))
(DEFUN DELETE--ONELINER-ONELINER (ONELINER &KEY TOKEN)
@@ -243,8 +252,8 @@ Result](#search-result) object."
(FORMAT NIL "~a" TOKEN))
""))))))
(DEXADOR:DELETE LAZYBONES-CLIENT.SHARED::REQ-STRING :COOKIE-JAR
- LAZYBONES-CLIENT.SHARED:*COOKIES* :HEADERS
- LAZYBONES-CLIENT.SHARED:*HEADERS*)))
+ LAZYBONES-CLIENT.SHARED:*COOKIES* :HEADERS
+ LAZYBONES-CLIENT.SHARED:*HEADERS*)))
(DEFUN POST--INVITE (&KEY TOKEN)
@@ -260,12 +269,12 @@ Result](#search-result) object."
""))))))
(IF LAZYBONES-CLIENT.SHARED:*BODY*
(DEXADOR:POST LAZYBONES-CLIENT.SHARED::REQ-STRING :CONTENT
- LAZYBONES-CLIENT.SHARED:*BODY* :COOKIE-JAR
- LAZYBONES-CLIENT.SHARED:*COOKIES* :HEADERS
- LAZYBONES-CLIENT.SHARED:*HEADERS*)
+ LAZYBONES-CLIENT.SHARED:*BODY* :COOKIE-JAR
+ LAZYBONES-CLIENT.SHARED:*COOKIES* :HEADERS
+ LAZYBONES-CLIENT.SHARED:*HEADERS*)
(DEXADOR:POST LAZYBONES-CLIENT.SHARED::REQ-STRING :COOKIE-JAR
- LAZYBONES-CLIENT.SHARED:*COOKIES* :HEADERS
- LAZYBONES-CLIENT.SHARED:*HEADERS*))))
+ LAZYBONES-CLIENT.SHARED:*COOKIES* :HEADERS
+ LAZYBONES-CLIENT.SHARED:*HEADERS*))))
(DEFUN DELETE--ACCESS-ACCESS (ACCESS &KEY TOKEN)
@@ -280,8 +289,8 @@ Result](#search-result) object."
(FORMAT NIL "~a" TOKEN))
""))))))
(DEXADOR:DELETE LAZYBONES-CLIENT.SHARED::REQ-STRING :COOKIE-JAR
- LAZYBONES-CLIENT.SHARED:*COOKIES* :HEADERS
- LAZYBONES-CLIENT.SHARED:*HEADERS*)))
+ LAZYBONES-CLIENT.SHARED:*COOKIES* :HEADERS
+ LAZYBONES-CLIENT.SHARED:*HEADERS*)))
(DEFUN POST--ACCESS ()
@@ -291,12 +300,12 @@ Result](#search-result) object."
(FORMAT NIL "/access") NIL)))
(IF LAZYBONES-CLIENT.SHARED:*BODY*
(DEXADOR:POST LAZYBONES-CLIENT.SHARED::REQ-STRING :CONTENT
- LAZYBONES-CLIENT.SHARED:*BODY* :COOKIE-JAR
- LAZYBONES-CLIENT.SHARED:*COOKIES* :HEADERS
- LAZYBONES-CLIENT.SHARED:*HEADERS*)
+ LAZYBONES-CLIENT.SHARED:*BODY* :COOKIE-JAR
+ LAZYBONES-CLIENT.SHARED:*COOKIES* :HEADERS
+ LAZYBONES-CLIENT.SHARED:*HEADERS*)
(DEXADOR:POST LAZYBONES-CLIENT.SHARED::REQ-STRING :COOKIE-JAR
- LAZYBONES-CLIENT.SHARED:*COOKIES* :HEADERS
- LAZYBONES-CLIENT.SHARED:*HEADERS*))))
+ LAZYBONES-CLIENT.SHARED:*COOKIES* :HEADERS
+ LAZYBONES-CLIENT.SHARED:*HEADERS*))))
(DEFUN POST--INVITE-REDEEM-CODE (CODE)
@@ -306,12 +315,12 @@ Result](#search-result) object."
(FORMAT NIL "/invite/redeem/~a" CODE) NIL)))
(IF LAZYBONES-CLIENT.SHARED:*BODY*
(DEXADOR:POST LAZYBONES-CLIENT.SHARED::REQ-STRING :CONTENT
- LAZYBONES-CLIENT.SHARED:*BODY* :COOKIE-JAR
- LAZYBONES-CLIENT.SHARED:*COOKIES* :HEADERS
- LAZYBONES-CLIENT.SHARED:*HEADERS*)
+ LAZYBONES-CLIENT.SHARED:*BODY* :COOKIE-JAR
+ LAZYBONES-CLIENT.SHARED:*COOKIES* :HEADERS
+ LAZYBONES-CLIENT.SHARED:*HEADERS*)
(DEXADOR:POST LAZYBONES-CLIENT.SHARED::REQ-STRING :COOKIE-JAR
- LAZYBONES-CLIENT.SHARED:*COOKIES* :HEADERS
- LAZYBONES-CLIENT.SHARED:*HEADERS*))))
+ LAZYBONES-CLIENT.SHARED:*COOKIES* :HEADERS
+ LAZYBONES-CLIENT.SHARED:*HEADERS*))))
(DEFUN PUT--CONTRIBUTOR-WHO-SIGNATURE (WHO &KEY TOKEN)
@@ -327,16 +336,18 @@ Result](#search-result) object."
""))))))
(IF LAZYBONES-CLIENT.SHARED:*BODY*
(DEXADOR:PUT LAZYBONES-CLIENT.SHARED::REQ-STRING :CONTENT
- LAZYBONES-CLIENT.SHARED:*BODY* :COOKIE-JAR
- LAZYBONES-CLIENT.SHARED:*COOKIES* :HEADERS
- LAZYBONES-CLIENT.SHARED:*HEADERS*)
+ LAZYBONES-CLIENT.SHARED:*BODY* :COOKIE-JAR
+ LAZYBONES-CLIENT.SHARED:*COOKIES* :HEADERS
+ LAZYBONES-CLIENT.SHARED:*HEADERS*)
(DEXADOR:PUT LAZYBONES-CLIENT.SHARED::REQ-STRING :COOKIE-JAR
- LAZYBONES-CLIENT.SHARED:*COOKIES* :HEADERS
- LAZYBONES-CLIENT.SHARED:*HEADERS*))))
+ LAZYBONES-CLIENT.SHARED:*COOKIES* :HEADERS
+ LAZYBONES-CLIENT.SHARED:*HEADERS*))))
(DEFUN PUT--CONTRIBUTOR-WHO-PASSWORD (WHO &KEY VALUE REPEATED CURRENT TOKEN)
- "Change a contributor's password."
+ "Change a contributor's password. CURRENT is the current
+password. VALUE is the new password. REPEATED must match VALUE. TOKEN
+is an API Access token."
(LET ((LAZYBONES-CLIENT.SHARED::REQ-STRING
(APPLY #'CONCATENATE 'STRING LAZYBONES-CLIENT.SHARED:*HOST* "/api"
(FORMAT NIL "/contributor/~a/password" WHO)
@@ -360,12 +371,12 @@ Result](#search-result) object."
""))))))
(IF LAZYBONES-CLIENT.SHARED:*BODY*
(DEXADOR:PUT LAZYBONES-CLIENT.SHARED::REQ-STRING :CONTENT
- LAZYBONES-CLIENT.SHARED:*BODY* :COOKIE-JAR
- LAZYBONES-CLIENT.SHARED:*COOKIES* :HEADERS
- LAZYBONES-CLIENT.SHARED:*HEADERS*)
+ LAZYBONES-CLIENT.SHARED:*BODY* :COOKIE-JAR
+ LAZYBONES-CLIENT.SHARED:*COOKIES* :HEADERS
+ LAZYBONES-CLIENT.SHARED:*HEADERS*)
(DEXADOR:PUT LAZYBONES-CLIENT.SHARED::REQ-STRING :COOKIE-JAR
- LAZYBONES-CLIENT.SHARED:*COOKIES* :HEADERS
- LAZYBONES-CLIENT.SHARED:*HEADERS*))))
+ LAZYBONES-CLIENT.SHARED:*COOKIES* :HEADERS
+ LAZYBONES-CLIENT.SHARED:*HEADERS*))))
(DEFUN PUT--CONTRIBUTOR-WHO-LOCKED (WHO &KEY VALUE TOKEN)
@@ -386,12 +397,12 @@ contributor for making edits or adding new oneliners."
""))))))
(IF LAZYBONES-CLIENT.SHARED:*BODY*
(DEXADOR:PUT LAZYBONES-CLIENT.SHARED::REQ-STRING :CONTENT
- LAZYBONES-CLIENT.SHARED:*BODY* :COOKIE-JAR
- LAZYBONES-CLIENT.SHARED:*COOKIES* :HEADERS
- LAZYBONES-CLIENT.SHARED:*HEADERS*)
+ LAZYBONES-CLIENT.SHARED:*BODY* :COOKIE-JAR
+ LAZYBONES-CLIENT.SHARED:*COOKIES* :HEADERS
+ LAZYBONES-CLIENT.SHARED:*HEADERS*)
(DEXADOR:PUT LAZYBONES-CLIENT.SHARED::REQ-STRING :COOKIE-JAR
- LAZYBONES-CLIENT.SHARED:*COOKIES* :HEADERS
- LAZYBONES-CLIENT.SHARED:*HEADERS*))))
+ LAZYBONES-CLIENT.SHARED:*COOKIES* :HEADERS
+ LAZYBONES-CLIENT.SHARED:*HEADERS*))))
(DEFUN GET--CONTRIBUTOR-WHO (WHO)
@@ -400,6 +411,27 @@ contributor for making edits or adding new oneliners."
(APPLY #'CONCATENATE 'STRING LAZYBONES-CLIENT.SHARED:*HOST* "/api"
(FORMAT NIL "/contributor/~a" WHO) NIL)))
(DEXADOR:GET LAZYBONES-CLIENT.SHARED::REQ-STRING :COOKIE-JAR
- LAZYBONES-CLIENT.SHARED:*COOKIES* :HEADERS
- LAZYBONES-CLIENT.SHARED:*HEADERS*)))
+ LAZYBONES-CLIENT.SHARED:*COOKIES* :HEADERS
+ LAZYBONES-CLIENT.SHARED:*HEADERS*)))
+
+
+(DEFUN POST--SNAPSHOT (&KEY TOKEN)
+ "Snapshot the datastore. Do this after upgrade"
+ (LET ((LAZYBONES-CLIENT.SHARED::REQ-STRING
+ (APPLY #'CONCATENATE 'STRING LAZYBONES-CLIENT.SHARED:*HOST* "/api"
+ (FORMAT NIL "/snapshot")
+ (WHEN (OR TOKEN)
+ (LIST "?"
+ (IF TOKEN
+ (CONCATENATE 'STRING (SYMBOL-NAME 'TOKEN) "="
+ (FORMAT NIL "~a" TOKEN))
+ ""))))))
+ (IF LAZYBONES-CLIENT.SHARED:*BODY*
+ (DEXADOR:POST LAZYBONES-CLIENT.SHARED::REQ-STRING :CONTENT
+ LAZYBONES-CLIENT.SHARED:*BODY* :COOKIE-JAR
+ LAZYBONES-CLIENT.SHARED:*COOKIES* :HEADERS
+ LAZYBONES-CLIENT.SHARED:*HEADERS*)
+ (DEXADOR:POST LAZYBONES-CLIENT.SHARED::REQ-STRING :COOKIE-JAR
+ LAZYBONES-CLIENT.SHARED:*COOKIES* :HEADERS
+ LAZYBONES-CLIENT.SHARED:*HEADERS*))))
diff --git a/oneliners.cli.asd b/oneliners.cli.asd
index 5815b6d..fa3f9b8 100644
--- a/oneliners.cli.asd
+++ b/oneliners.cli.asd
@@ -1,5 +1,5 @@
(defsystem "oneliners.cli"
- :version "alpha-0.5.0"
+ :version "alpha-0.6.0"
:author "Colin Okay"
:license "AGPLv3"
:depends-on ("trivial-clipboard"
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.