Copy global boards-defaults to every board-config

This commit is contained in:
Felisp 2024-07-28 18:26:38 +02:00
parent cd540fda36
commit 6391e115d1

View file

@ -57,19 +57,15 @@
(edn/read (java.io.PushbackReader. r)))))) (edn/read (java.io.PushbackReader. r))))))
(defn config-fill-board-defaults (defn config-fill-board-defaults
"Fills every enabled board with default values" "Fills every enabled board with default config values"
[conifg] [config]
;; Získat všechny klíče desek které musíme vyplnit (let [defaults (:boards-defaults config)]
;; Každý klíč mergnout s default mapou (update-in config
(u/map-apply-defaults ) '(:boards-enabled)
(let [board-defaults (:boards-default config) (fn [mp]
boards (keys (:boards-enabled config))] (u/fmap (fn [k v]
(update-in config '(:boards-enabled) (fn [val] (u/map-apply-defaults v defaults))
(u/fmap (fn []) mp)))))
val) )
;; just do fmap of boards
())
)
(defn get-some-config (defn get-some-config
"Attempts to get config somehow, "Attempts to get config somehow,
@ -79,13 +75,12 @@
;; args do not include path to executable so first arg ;; args do not include path to executable so first arg
;; should be config file ;; should be config file
[cmd-args] [cmd-args]
(let [file-to-try (u/nil?-else (first cmd-args) (config-fill-board-defaults
(let [file-to-try (u/nil?-else (first cmd-args)
"./config.edn")] "./config.edn")]
(u/when-else (load-config file-to-try) (u/when-else (load-config file-to-try)
(println "WARN: Using default internal config because suggessted file: '" file-to-try "' not found.") (println "WARN: Using default internal config because suggessted file: '" file-to-try "' not found.")
CONFIG-DEFAULT))) CONFIG-DEFAULT))))
;;TODO: We want to copy default board-local config into every board, that way we won't have to always look
;; into defaults, but
;; Todo: Add option to write default config to stdout ;; Todo: Add option to write default config to stdout
(defn -main (defn -main