-
Notifications
You must be signed in to change notification settings - Fork 0
/
api-client.lisp
36 lines (29 loc) · 1.04 KB
/
api-client.lisp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
(require :drakma)
(require :cl-json)
(defpackage :quicklisp-apropos-client
(:use :cl))
(in-package :quicklisp-apropos-client)
(defvar *index-url*)
(defun format-query (query)
(when (stringp query)
(return-from format-query query))
(when (listp query)
()))
(defun query-api (query)
(json:decode-json-from-source
(drakma:http-request *index-url*
:parameters (list (cons "q" query))
:want-stream t)))
(defun print-result (result)
(format t "~a ~a in system ~a~%"
(alexandria:assoc-value result :type)
(alexandria:assoc-value result :name)
(alexandria:assoc-value result :system))
(when (alexandria:assoc-value result :doc)
(format t "~%~a~%" (alexandria:assoc-value result :doc))))
(defun print-results (results)
(format t "~a results:~%~%" (length results))
(format t "--------------------------------------------------------------------------------~%")
(dolist (result results)
(print-result result)
(format t "--------------------------------------------------------------------------------~%")))