49cc7588b034b828c7360c07fb5b88350e840c37
commit 49cc7588b034b828c7360c07fb5b88350e840c37
Author: Simon Watson <spw01@protonmail.com>
Date: Sat Aug 12 16:55:52 2023 -0400

Basic config reloader

diff --git a/pest.lisp b/pest.lisp
index 2846212..6ead371 100644
--- a/pest.lisp
+++ b/pest.lisp
@@ -9,22 +9,29 @@
(loop for line = (read-line fh nil)
while line
do (format out "~a~%" line)))))
- (clop:parse file-content)))
- (format T "~A: File not found" config-path))))
+ (clop:parse file-content))))))

-(defvar *config* (config-parse "/home/swatson/Repos/cl-pest/config.toml"))
+(defvar *config* NIL)

;; Colors
-(defvar *fg* (progn
- (if *config*
- (destructuring-bind (r g b) (subseq (assoc "fg" (cdr (assoc "colors" *config* :test #'equal)) :test #'equal) (- 4 3))
- (chlorophyll:create-rgb-color r g b))
- (chlorophyll:create-rgb-color 255 255 255))))
-(defvar *bg* (chlorophyll:create-rgb-color 0 0 0))
-(defvar *style* (chlorophyll:new-style
+(defvar *fg* NIL)
+(defvar *bg* NIL)
+(defvar *style* NIL)
+
+(defun reload-config ()
+ (setf *config* (config-parse "~/Repos/cl-pest/config.toml"))
+ (setf *fg* (if *config*
+ (destructuring-bind (r g b) (subseq (assoc "fg" (cdr (assoc "colors" *config* :test #'equal)) :test #'equal) (- 4 3))
+ (chlorophyll:create-rgb-color r g b))
+ (chlorophyll:create-rgb-color 255 255 255)))
+ (setf *bg* (if *config*
+ (destructuring-bind (r g b) (subseq (assoc "bg" (cdr (assoc "colors" *config* :test #'equal)) :test #'equal) (- 4 3))
+ (chlorophyll:create-rgb-color r g b))
+ (chlorophyll:create-rgb-color 0 0 0)))
+ (setf *style* (chlorophyll:new-style
:bold NIL
:foreground *fg*
- :background *bg*))
+ :background *bg*)))

;; Regex Scanners
;; TODO $HOME rendered as /home/user as opposed to ~
@@ -34,5 +41,5 @@
(ppcre:regex-replace *home-scan* (uiop:getenv "PWD") "~/"))

(defun main ()
- (setf *config* (config-parse "/home/swatson/Repos/cl-pest/config.toml"))
+ (reload-config)
(format T "~a λ " (chlorophyll:stylize *style* (pwd))))