 
 
 (defn- read-config
-  "Reads an EDN configuration file."
+  "Reads a Clojure configuration file."
   [path]
   (try
-    (edn/read-string
-      {:readers config-readers}
-      (slurp path))
+    (binding [*ns* *ns*]
+      (in-ns 'vault.tool.config.blob-stores)
+      (refer-clojure)
+      (require
+        '(vault.blob.store
+           [file :refer [file-store]]
+           [memory :refer [memory-store]]))
+      (load-string (slurp path)))
     (catch Exception e
       (println "Error loading config file" (str path))
       (.printStackTrace e)

  (str (get (System/getenv) "HOME") "/.config/vault"))


(def ^:private config-readers
  "Map of EDN readers for supported types in config files."
  {'vault/file-store file-store
   'vault/memory-store (fn [_] (memory-store))})


(defn- find-configs
  "Locates a sequence of configuration files with a particular name pattern.
  For example, if `dir` is '/foo/bar/' and `k` is :baz, then file
  '/foo/bar/baz.edn' comes first (if it exists), followed by the files in
  '/foo/bar/baz/' (if it exists) in lexical order."
  [dir k]
  (let [config-file (io/file dir (str (name k) ".edn"))
        config-dir  (io/file dir (str (name k)))]
    (filter
      identity

(ns vault.tool.config
  (:require
    [clojure.java.io :as io]
    [puget.printer :refer [cprint]]))


;; CONFIGURATION FILE LOADING
