2022-08-23 09:57:42 +00:00
|
|
|
#lang racket/base
|
2022-08-24 01:23:46 +00:00
|
|
|
(require racket/runtime-path)
|
2022-08-23 09:57:42 +00:00
|
|
|
|
|
|
|
(provide
|
|
|
|
config-get)
|
|
|
|
|
2022-08-24 01:23:46 +00:00
|
|
|
(define-runtime-path path-config "../config.txt")
|
|
|
|
|
2022-08-23 09:57:42 +00:00
|
|
|
(define (config-get key)
|
|
|
|
(hash-ref config key))
|
|
|
|
|
|
|
|
(define default-config
|
|
|
|
'((port . 10416)
|
|
|
|
(debug . #f)
|
|
|
|
(instance-is-official . #f) ; please don't turn this on, or you will make me very upset
|
|
|
|
(application-name . "BreezeWiki")))
|
|
|
|
|
|
|
|
(define config
|
|
|
|
(make-hasheq
|
|
|
|
(append
|
|
|
|
default-config
|
|
|
|
(with-handlers ([exn:fail:filesystem:errno? (λ (exn)
|
|
|
|
'())])
|
2022-08-24 01:23:46 +00:00
|
|
|
(call-with-input-file path-config
|
2022-08-23 09:57:42 +00:00
|
|
|
(λ (in)
|
|
|
|
(let loop ([alist '()])
|
|
|
|
(let ([key (read in)]
|
|
|
|
[value (read in)])
|
|
|
|
(if (eq? value eof)
|
|
|
|
alist
|
|
|
|
(loop (cons (cons key
|
|
|
|
(cond
|
|
|
|
[(eq? value 'true) #t]
|
|
|
|
[(eq? value 'false) #f]
|
|
|
|
[#t value]))
|
|
|
|
alist)))))))))))
|