Last active
August 29, 2015 14:08
-
-
Save PuercoPop/13eab23cf2f76a429dc3 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defpackage #:dixit/conf | |
(:use :cl) | |
(:export | |
#:*db-name* | |
#:*db-host* | |
#:*db-port* | |
#:*db-timeout*)) | |
(in-package :dixit/conf) | |
(defvar *db-name*) | |
(defvar *db-host*) | |
(defvar *db-port*) | |
(defvar *db-timeout*) | |
(defun load-config (config-file) | |
;; TODO: Fix For YAML or another format. | |
(with-open-file (in config-file :direction :input :external-format '(:utf-8)) | |
(loop | |
:for line := (read in nil 'eof) | |
:until (eq line 'eof) | |
:do | |
(if (find-symbol (symbol-name (car line)) | |
(find-package :dixit/conf)) | |
(setf (symbol-value (car line)) (cadr line)) | |
(error "Unrecognized Option ~A" (car line)))))) | |
;; REPL | |
DIXIT/CONF> (load-config (asdf/system:system-relative-pathname :dixit "dixit.config")) | |
((#1="test" #1#) (#2="127.0.0.1" #2#) (28015 28015)) | |
DIXIT/CONF> *db-name* | |
; Evaluation errored on #<UNBOUND-VARIABLE *DB-NAME* {1004C08513}> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;; -*- mode: lisp -*- | |
(*db-name* "test") | |
(*db-host* "127.0.0.1") | |
(*db-port* 28015) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment