From e230e33a55b3e63c5d84c9afc9d26914577ec480 Mon Sep 17 00:00:00 2001 From: Felisp Date: Fri, 5 Jan 2024 14:16:01 +0100 Subject: [PATCH] Add config loading from custom file, default file and internal config --- src/rss_thread_watch/core.clj | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/src/rss_thread_watch/core.clj b/src/rss_thread_watch/core.clj index f564bb4..9b25b22 100644 --- a/src/rss_thread_watch/core.clj +++ b/src/rss_thread_watch/core.clj @@ -18,7 +18,8 @@ [ring.adapter.jetty :as jetty] [ring.middleware.params :as rp] [rss-thread-watch.watcher :as watcher] - [rss-thread-watch.feed-generator :as feed]) + [rss-thread-watch.feed-generator :as feed] + [rss-thread-watch.utils :as u]) (:gen-class)) ;; Internal default config @@ -62,17 +63,18 @@ lastly uses default internal" ;; args do not include path to executable so first arg ;; should be config file - [cmd-args]) + [cmd-args] + (let [file-to-try (u/nil?-else (first cmd-args) + "./config.edn")] + (u/when-else2 (load-config file-to-try) + (println "WARN: Using default internal config because suggessted " file-to-try " not found.") + CONFIG-DEFAULT))) ;; Todo: Add option to write default config to stdout -;; Todo: Discover config file if not arguments else -;; ./config.edn if not found spit error about -;; using default (defn -main "Entry point, starts webserver" [& args] - ;; Parse and validate config - ;; Think of a way to start repeated download for every catalog efficiently + ;; Todo: Think of a way to start repeated download for every catalog efficiently (let [config (get-some-config args)]) (println args) (System/exit 0)