mirror of
https://codeberg.org/cage/tinmop/
synced 2025-02-17 08:10:36 +01:00
- create an empty config file if the user did not provided oopne, instread of printing an error and exit.
This commit is contained in:
parent
72254f981a
commit
382c61818d
@ -31,7 +31,7 @@
|
||||
|
||||
(defun setup-bindings ()
|
||||
"This is where an UI event is bound to a function the event nil is
|
||||
the event that is fired wnen no input from user (key pressed mouse
|
||||
the event that is fired when no input from user (key pressed mouse
|
||||
etc.) happened"
|
||||
(windows:with-croatoan-window (croatoan-window specials:*main-window*)
|
||||
(bind croatoan-window
|
||||
@ -101,14 +101,25 @@ etc.) happened"
|
||||
(program-events:push-event event)))
|
||||
|
||||
(defun load-configuration-files ()
|
||||
(swconf:load-config-file swconf:+shared-conf-filename+)
|
||||
(swconf:load-config-file swconf:+conf-filename+))
|
||||
(handler-case
|
||||
(swconf:load-config-file swconf:+shared-conf-filename+)
|
||||
(error (e)
|
||||
(format *error-output* "~a~%" e)
|
||||
(os-utils:exit-program 1)))
|
||||
(handler-bind ((error
|
||||
#'(lambda (e)
|
||||
(format *error-output*
|
||||
(_ "Non fatal error~%~a~%Tinmop will add an empty file for you. This file will be enough to use the program as a gemini client but to connect to pleroma the file must be properly filled.~%Consult the manpage ~a(1) for more details")
|
||||
e
|
||||
+program-name+)
|
||||
(invoke-restart 'res:create-empty-in-home))))
|
||||
(swconf:load-config-file swconf:+conf-filename+)))
|
||||
|
||||
(defun init ()
|
||||
"Initialize the program"
|
||||
(res:init)
|
||||
(load-configuration-files)
|
||||
(init-db)
|
||||
;; (res:init)
|
||||
;; (load-configuration-files)
|
||||
;; (init-db)
|
||||
(gemini-client:init-default-gemini-theme)
|
||||
(db-utils:with-ready-database (:connect nil)
|
||||
(complete:initialize-complete-username-cache)
|
||||
@ -171,6 +182,9 @@ etc.) happened"
|
||||
(defun main ()
|
||||
"The entry point function of the program"
|
||||
(init-i18n)
|
||||
(res:init)
|
||||
(load-configuration-files)
|
||||
(init-db)
|
||||
(command-line:manage-opts)
|
||||
(if command-line:*script-file*
|
||||
(load-script-file)
|
||||
|
@ -411,6 +411,7 @@
|
||||
:home-confdir
|
||||
:return-home-filename
|
||||
:return-system-filename
|
||||
:create-empty-in-home
|
||||
:get-config-file
|
||||
:get-sys-config-file
|
||||
:get-data-file))
|
||||
|
@ -52,15 +52,16 @@
|
||||
((fs:file-exists-p system-file)
|
||||
system-file)
|
||||
(t
|
||||
(let ((msg (_ "Unrecoverable error: cannot find ~s in either ~s or ~s.")))
|
||||
(let ((msg (_ "Cannot find ~s in either ~s or ~s.")))
|
||||
(restart-case
|
||||
(error (format nil msg path system-file home-file))
|
||||
(return-home-filename (e)
|
||||
(declare (ignore e))
|
||||
(return-home-filename ()
|
||||
home-file)
|
||||
(return-system-filename (e)
|
||||
(declare (ignore e))
|
||||
system-file)))))))
|
||||
(return-system-filename ()
|
||||
system-file)
|
||||
(create-empty-in-home ()
|
||||
(fs:create-file home-file :skip-if-exists t)
|
||||
(get-resource-file system-dir home-dir path))))))))
|
||||
|
||||
(defun get-config-file (path)
|
||||
(get-resource-file +sys-conf-dir+ (home-confdir) path))
|
||||
|
@ -413,30 +413,25 @@
|
||||
purge-cache-days-offset)
|
||||
|
||||
(defun load-config-file (&optional (virtual-filepath +conf-filename+))
|
||||
(handler-case
|
||||
(progn
|
||||
(let* ((file (res:get-config-file virtual-filepath))
|
||||
(tree (parse-config (fs:namestring->pathname file))))
|
||||
(loop for entry in tree do
|
||||
(let ((key (first entry))
|
||||
(value (second entry)))
|
||||
(cond
|
||||
((or (eq +key-color-re+ key)
|
||||
(eq +key-ignore-user-re+ key))
|
||||
(setf (access:accesses *software-configuration* key)
|
||||
(append (access:accesses *software-configuration* key)
|
||||
(list value))))
|
||||
((keywordp key)
|
||||
(setf (access:accesses *software-configuration* key) value))
|
||||
(t
|
||||
(multiple-value-bind (rest all)
|
||||
(apply #'access:set-accesses value *software-configuration* key)
|
||||
(declare (ignore rest))
|
||||
(setf *software-configuration* all))))))
|
||||
*software-configuration*))
|
||||
(error (e)
|
||||
(format *error-output* "~a~%" e)
|
||||
(os-utils:exit-program 1))))
|
||||
(let* ((file (res:get-config-file virtual-filepath))
|
||||
(tree (parse-config (fs:namestring->pathname file))))
|
||||
(loop for entry in tree do
|
||||
(let ((key (first entry))
|
||||
(value (second entry)))
|
||||
(cond
|
||||
((or (eq +key-color-re+ key)
|
||||
(eq +key-ignore-user-re+ key))
|
||||
(setf (access:accesses *software-configuration* key)
|
||||
(append (access:accesses *software-configuration* key)
|
||||
(list value))))
|
||||
((keywordp key)
|
||||
(setf (access:accesses *software-configuration* key) value))
|
||||
(t
|
||||
(multiple-value-bind (rest all)
|
||||
(apply #'access:set-accesses value *software-configuration* key)
|
||||
(declare (ignore rest))
|
||||
(setf *software-configuration* all))))))
|
||||
*software-configuration*))
|
||||
|
||||
;;;; end of parser
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user