diff options
author | Teddy Wing | 2022-05-08 00:23:34 +0200 |
---|---|---|
committer | Teddy Wing | 2022-05-08 00:28:54 +0200 |
commit | 8b2a0beca97552808a4a8c55308a0fd93af27375 (patch) | |
tree | 73025349877489b621927db166fd35878db19c2c | |
parent | 9553c53d0064da9d1c5c1af303746f17efeb4f71 (diff) | |
download | wajir-8b2a0beca97552808a4a8c55308a0fd93af27375.tar.bz2 |
Move configuration into a `config` object
We can later make a config from command line arguments.
Also don't require "https://" prefix from endpoint config. Doesn't make
sense to require that in the input when we can add it in the program.
-rw-r--r-- | src/config.lisp | 19 | ||||
-rw-r--r-- | src/main.lisp | 18 | ||||
-rw-r--r-- | wajir.asd | 1 |
3 files changed, 33 insertions, 5 deletions
diff --git a/src/config.lisp b/src/config.lisp new file mode 100644 index 0000000..66e7ac9 --- /dev/null +++ b/src/config.lisp @@ -0,0 +1,19 @@ +(in-package :wajir) + +(defclass config () + ((login + :initarg :login + :reader login + :documentation "Jira login email address") + (token + :initarg :token + :reader token + :documentation "Jira authentication token") + (endpoint + :initarg :endpoint + :reader endpoint + :documentation "Jira site URL (e.g. example.atlassian.net)") + (jql + :initarg :jql + :reader jql + :documentation "JQL querying issues to watch"))) diff --git a/src/main.lisp b/src/main.lisp index 094bb41..c441207 100644 --- a/src/main.lisp +++ b/src/main.lisp @@ -7,17 +7,25 @@ ;; Send email to ^maildir^program^ containing message with issue metadata ;; Continue to next page - (let ((basic-auth-token (cl-base64:string-to-base64-string - (format nil "~A:~A" "name@example.com" "atlassian-token")))) + (let* ((config (make-instance 'config + :login "name@example.com" + :token "atlassian-token" + :endpoint "example.atlassian.net" + :jql "project = \"FAKE\" AND watcher != currentUser() AND key > \"FAKE-100\" ORDER BY created DESC")) + (basic-auth-token (cl-base64:string-to-base64-string + (format nil + "~A:~A" + (login config) + (token config))))) (fetch-issues - "https://example.atlassian.net" - "project = \\\"FAKE\\\" AND watcher != currentUser() AND key > \\\"FAKE-100\\\" ORDER BY created DESC" + (endpoint config) + (jql config) :basic-auth-token basic-auth-token))) (defun fetch-issues (endpoint jql &key basic-auth-token) (jzon:parse - (dex:post (format nil "~A/rest/api/3/search" endpoint) + (dex:post (format nil "https://~A/rest/api/3/search" endpoint) :content (jzon:stringify `((:jql . ,jql) @@ -18,6 +18,7 @@ :components ((:module "src" :serial t :components ((:file "package") + (:file "config") (:file "main")))) :build-operation "program-op" |