 (ns figwheel-sidecar.config-check.type-check
   (:require
    [clojure.pprint :as pprint]
+
+   [fipp.visit :refer [visit]]
+   [fipp.edn :as fedn]
    [fipp.engine :refer [pprint-document]]
+
    [figwheel-sidecar.config-check.ansi :refer [color]]
    [clj-fuzzy.metrics :as metrics]
    [clojure.walk :as walk]
    [clojure.string :as string]
    [clojure.set :refer [difference]]))
+
+(def edn-printer (fedn/map->EdnPrinter {}))
+
+(defn fipp-format-data [data]
+  (visit edn-printer data))
 
 (defn log [x] (prn x) x)
 


(defn print-path [[x & xs] leaf-node edn]
  (if (and x (get edn x))
    [:group (if (and (not (map? edn)) (integer? x))
              "[{"
              (str (pr-str x ) " {"))
     [:nest 2
      :line
      (print-path xs leaf-node (get edn x))
      ]
     (if (and (not (map? edn)) (integer? x))
       "}]"
       "}")]
    leaf-node))

(defn print-path-error
  ([{:keys [path orig-config] :as error} leaf-node document]


#_(required-keys 'FigOpts :hello :goodbye)

#_(defn doc-type? [x]
  (and (map? x)
       (= #{:content :example} (set (keys x)))
       (let [{:keys [example content]} x]
         (or (fn? example)
             (string? example)))))

(defn doc
  ([root type-doc kd]
   (cons [root :doc-type type-doc]
         (mapv (fn [[k d]] [root :doc-key k d]) kd)))
  ([root type-doc]
   (doc root type-doc [])))

