aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--build-app.lisp19
-rw-r--r--oneliners.api-client.lisp52
-rw-r--r--src/lib.lisp10
3 files changed, 59 insertions, 22 deletions
diff --git a/build-app.lisp b/build-app.lisp
index 6460d9e..5d4f069 100644
--- a/build-app.lisp
+++ b/build-app.lisp
@@ -27,8 +27,8 @@ my1337pw.")
;;; CLON SYNOPSIS DEFINITION
(defsynopsis (:postfix "[TERMS ...] | N [ARGS ...]")
- (group (:header "Search")
- (text :contents "Usage: ol [OPTIONS] [TERMS ...]")
+ (group (:header "SEARCH")
+ (text :contents " ")
(text :contents "Each term may be a command name or some tag like 'server' or 'tunnel'")
(lispobj :long-name "limit"
:argument-type :optional
@@ -39,8 +39,8 @@ my1337pw.")
(flag :long-name "not-flagged"
:description "Request that no flagged oneliners are returned."))
(text :contents " ")
- (group (:header "Running Oneliners")
- (text :contents "Usage: ol [OPTIONS] N [ARGS ...]")
+ (group (:header "RUNNING ONELINERS")
+ (text :contents " ")
(text :contents "Runs the Nth search result with possible arguments ARGS.")
(flag :long-name "clip"
:description "Force an attempt to copy the oneliner to the clipboard instead of running it."))
@@ -49,15 +49,15 @@ my1337pw.")
(flag :long-name "help"
:description "Print this help menu.")
(enum :long-name "help-topic"
- :enum '(:contributor :adding :invites)
+ :enum '(:access :wiki :invites)
:argument-name "TOPIC"
- :description "Print help for a topic. Topics are: adding, contributor, invites"))
- (group (:header "Adding" :hidden t)
+ :description "Print help for a topic. Topics are: wiki, access, invites"))
+ (group (:header "Wiki" :hidden t)
(flag :long-name "add"
:description "Intaractively add a oneliner and update the wiki.")
(flag :long-name "update"
:description "Interactively edit a oneliner and update the wiki."))
- (group (:header "Contributor" :hidden t)
+ (group (:header "Access" :hidden t)
(flag :long-name "login"
:description "Attempt to login to your contributor account. ARGS are interpreted as USERNAME PASSWORD. Success will return ab API token, writing it automatically into your config file.")
(flag :long-name "revoke"
@@ -108,6 +108,9 @@ than the users."
((getopt :long-name "invite")
(cli::request-invite-code))
+ ((getopt :long-name "revoke")
+ (cli::revoke-access))
+
((getopt :long-name "add")
(oneliners.cli::add-new-oneliner))
diff --git a/oneliners.api-client.lisp b/oneliners.api-client.lisp
index 2ae2c65..563d088 100644
--- a/oneliners.api-client.lisp
+++ b/oneliners.api-client.lisp
@@ -5,16 +5,16 @@
(defpackage #:ONELINERS.API-CLIENT
(:use :cl :lazybones-client.shared)
(:export #:*host* #:*body* #:*headers* #:*cookies* #:request-with
- #:GET--ONELINERS
- #:GET--ONELIERS
- #:PUT--ONELINER-ENTRY-FLAG
- #:PATCH--ONELINER-ENTRY-EDIT
- #:PUT--ONELINER-ONELINER-LOCKED
- #:POST--ONELINER
- #:POST--INVITE
- #:DELETE--ACCESS-CONTRIBUTOR
- #:POST--ACCESS
- #:POST--INVITE-REDEEM-CODE))
+ #:GET--ONELINERS
+#:GET--ONELIERS
+#:PUT--ONELINER-ENTRY-FLAG
+#:PATCH--ONELINER-ENTRY-EDIT
+#:PUT--ONELINER-ONELINER-LOCKED
+#:POST--ONELINER
+#:POST--INVITE
+#:DELETE--ACCESS-ACCESS
+#:POST--ACCESS
+#:POST--INVITE-REDEEM-CODE))
(in-package :ONELINERS.API-CLIENT)
@@ -69,6 +69,32 @@ 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*
+ (FORMAT NIL "/oneliners")
+ (WHEN (OR TAGS LIMIT NOTFLAGGED)
+ (LIST "?"
+ (IF TAGS
+ (CONCATENATE 'STRING (SYMBOL-NAME 'TAGS) "="
+ (FORMAT NIL "~a" TAGS))
+ "")
+ (IF LIMIT
+ (CONCATENATE 'STRING "&" (SYMBOL-NAME 'LIMIT) "="
+ (FORMAT NIL "~a" LIMIT))
+ "")
+ (IF NOTFLAGGED
+ (CONCATENATE 'STRING "&" (SYMBOL-NAME 'NOTFLAGGED)
+ "=" (FORMAT NIL "~a" NOTFLAGGED))
+ ""))))))
+ (DEXADOR:GET LAZYBONES-CLIENT.SHARED::REQ-STRING :COOKIE-JAR
+ LAZYBONES-CLIENT.SHARED:*COOKIES* :HEADERS
+ LAZYBONES-CLIENT.SHARED:*HEADERS*)))
+
+
+(DEFUN GET--ONELIERS (&KEY TAGS LIMIT NOTFLAGGED)
+ "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*
(FORMAT NIL "/oneliers")
(WHEN (OR TAGS LIMIT NOTFLAGGED)
(LIST "?"
@@ -198,11 +224,11 @@ Result](#search-result) object."
LAZYBONES-CLIENT.SHARED:*HEADERS*))))
-(DEFUN DELETE--ACCESS-CONTRIBUTOR (CONTRIBUTOR &KEY TOKEN)
- NIL
+(DEFUN DELETE--ACCESS-ACCESS (ACCESS &KEY TOKEN)
+ "Revoke access of CONTRIBUTOR"
(LET ((LAZYBONES-CLIENT.SHARED::REQ-STRING
(APPLY #'CONCATENATE 'STRING LAZYBONES-CLIENT.SHARED:*HOST*
- (FORMAT NIL "/access/~a" CONTRIBUTOR)
+ (FORMAT NIL "/access/~a" ACCESS)
(WHEN (OR TOKEN)
(LIST "?"
(IF TOKEN
diff --git a/src/lib.lisp b/src/lib.lisp
index 332dd07..3dd6e7d 100644
--- a/src/lib.lisp
+++ b/src/lib.lisp
@@ -140,7 +140,7 @@ the directories that appear in the value of that variable."
(ensure-config)
(api:request-with
(:host (host))
- (let ((invite (api:post--invite :token (api-token))))
+ (let ((invite (jonathan:parse (api:post--invite :token (api-token)))))
(format t "Invite Code: ~a~%Expires: ~a~%"
(getf invite :code)
(getf invite :expires)))))
@@ -166,6 +166,13 @@ the directories that appear in the value of that variable."
(api:post--invite-redeem-code token)
(format t "Account made for ~a. You may log in now~%" name)))
+(defun revoke-access ()
+ (ensure-config)
+ (api:request-with
+ (:host (host))
+ (api:delete--access-access (api-token) :token (api-token))))
+
+
(defun cache-search-results-to-last-search-file (results)
(with-open-file (output (last-search-file) :direction :output :if-exists :supersede)
(print results output)))
@@ -180,6 +187,7 @@ the directories that appear in the value of that variable."
(getf oneliner :brief))
(format t "~% ~a~%~%" (getf oneliner :oneliner)))
+
(defun search-for-oneliners (terms limit not-flagged-p)
(assert (loop for term in terms never (find #\, term) ))
(ensure-config)