diff options
| author | 2025-10-18 05:36:44 +0300 | |
|---|---|---|
| committer | 2025-10-18 05:36:44 +0300 | |
| commit | 6b216e2b7c4b8f4a54551ab3f01c2d2695a99d5b (patch) | |
| tree | 03f2757896686afd058303b9210e792fce856497 /src/config.lisp | |
| parent | Manage dependencies with ocicl :) (diff) | |
| download | ukkoclot-6b216e2b7c4b8f4a54551ab3f01c2d2695a99d5b.tar.gz ukkoclot-6b216e2b7c4b8f4a54551ab3f01c2d2695a99d5b.tar.xz ukkoclot-6b216e2b7c4b8f4a54551ab3f01c2d2695a99d5b.zip | |
Revert "Added a SWANK server"
This reverts commit 5db1d491cecd9b610e9693d10b5015822429d261.
Diffstat (limited to 'src/config.lisp')
| -rw-r--r-- | src/config.lisp | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/src/config.lisp b/src/config.lisp index 1bac762..55575bb 100644 --- a/src/config.lisp +++ b/src/config.lisp | |||
| @@ -2,13 +2,16 @@ | |||
| 2 | ;; SPDX-FileCopyrightText: 2025 Uko Kokņevičs <perkontevs@gmail.com> | 2 | ;; SPDX-FileCopyrightText: 2025 Uko Kokņevičs <perkontevs@gmail.com> |
| 3 | (defpackage :ukkoclot/config | 3 | (defpackage :ukkoclot/config |
| 4 | (:use :c2cl :ukkoclot/hash-tables) | 4 | (:use :c2cl :ukkoclot/hash-tables) |
| 5 | (:documentation | ||
| 6 | "Stuff for loading the configuration of the bot") | ||
| 5 | (:export | 7 | (:export |
| 6 | :config-load :config-merge | 8 | :config-load :config-merge |
| 7 | :config-p | 9 | :config-p |
| 8 | :config-bot-name :config-bot-token :config-db-path :config-dev-group :config-owner :config-swank-port)) | 10 | :config-bot-name :config-bot-token :config-db-path :config-dev-group :config-owner)) |
| 9 | (in-package :ukkoclot/config) | 11 | (in-package :ukkoclot/config) |
| 10 | 12 | ||
| 11 | (defmacro defconfig (&rest slots-and-types) | 13 | (defmacro defconfig (&rest slots-and-types) |
| 14 | "Macro to make the config struct creation easier." | ||
| 12 | `(defstruct config | 15 | `(defstruct config |
| 13 | ,@(loop for (name type) on slots-and-types by #'cddr | 16 | ,@(loop for (name type) on slots-and-types by #'cddr |
| 14 | collect `(,(intern (symbol-name name)) (error "No value given for ~A" ,name) :type ,type :read-only t)))) | 17 | collect `(,(intern (symbol-name name)) (error "No value given for ~A" ,name) :type ,type :read-only t)))) |
| @@ -18,12 +21,13 @@ | |||
| 18 | :bot-token string | 21 | :bot-token string |
| 19 | :db-path string | 22 | :db-path string |
| 20 | :dev-group integer | 23 | :dev-group integer |
| 21 | :owner integer | 24 | :owner integer) |
| 22 | :swank-port (integer 1 65536)) | ||
| 23 | 25 | ||
| 24 | (defun config-load (filename) | 26 | (defun config-load (filename) |
| 27 | "Load the config from the given `filename'. All entries must be specified." | ||
| 25 | (apply #'make-config (with-open-file (f filename) (read f)))) | 28 | (apply #'make-config (with-open-file (f filename) (read f)))) |
| 26 | 29 | ||
| 27 | (defun config-merge (config filename) | 30 | (defun config-merge (config filename) |
| 31 | "Merge the current config with new entries from `filename'." | ||
| 28 | (loop for (name value) on (with-open-file (f filename) (read f)) by #'cddr do | 32 | (loop for (name value) on (with-open-file (f filename) (read f)) by #'cddr do |
| 29 | (setf (slot-value config (intern (symbol-name name) :ukkoclot/config)) value))) | 33 | (setf (slot-value config (intern (symbol-name name) :ukkoclot/config)) value))) |