diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/lib.lisp | 31 |
1 files changed, 19 insertions, 12 deletions
diff --git a/src/lib.lisp b/src/lib.lisp index 3eefc63..58d071c 100644 --- a/src/lib.lisp +++ b/src/lib.lisp @@ -132,14 +132,14 @@ the directories that appear in the value of that variable." (progn ,@body) (format t "The last search was shorter than ~a" ,nvar))))) -;;; API REQUEST FUNCTIONS - (defun print-item-explanation (number) (with-cached-result (ol number) (when (getf ol :explanation) (princ #\newline) (princ (getf ol :explanation))))) +;;; API REQUEST FUNCTIONS + (defun flag-item (item-number) (with-cached-result (ol item-number) (ensure-config) @@ -401,6 +401,22 @@ the directories that appear in the value of that variable." (format t "~% by: ~12a tags: ~{~a~^ ~}" (getf oneliner :createdby) (getf oneliner :tags)) (format t "~%~% ~a~%~%" (getf oneliner :oneliner))) +(defun cache-and-print-search-response (response) + (cache-search-results-to-last-search-file + (loop for number from 1 + for oneliner in (getf (jonathan:parse response) :oneliners) + collect (list* :result-number number oneliner) + do (print-oneliner-result-for-user number oneliner)))) + +(defun all-flagged-oneliners (&optional limit) + (ensure-config) + (api:request-with + (:host (host)) + (let ((response + (if limit + (api:get--oneliners-all-flagged :limit limit) + (api:get--oneliners-all-flagged)))) + (cache-and-print-search-response response)))) (defun search-for-oneliners (terms limit not-flagged-p) (assert (loop for term in terms never (find #\, term) )) @@ -411,16 +427,7 @@ the directories that appear in the value of that variable." (api:get--oneliners :tags (str:join "," terms) :limit limit :notflagged (if not-flagged-p "true" "false"))))) - (handler-case - (a:when-let (oneliners - (getf (jonathan:parse response) :oneliners)) - (cache-search-results-to-last-search-file - (loop for number from 1 - for oneliner in oneliners - collect (list* :result-number number oneliner) - do (print-oneliner-result-for-user number oneliner))) - (format t "Run a command with: ol NUMBER [ARGS...]~%"))))) - + (cache-and-print-search-response response))) ;;; RUNNING THINGS IN THE SHELL. |