Add config loading from custom file, default file and internal config

This commit is contained in:
Felisp 2024-01-05 14:16:01 +01:00
parent 9bb30b9863
commit e230e33a55

View file

@ -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)