(ns rendermarkdown
  (:require ["fs" :as fs]
            ["marked" :as marked]))

(defn main [args]
  (try
    (if-let [file-path (first args)]
      (let [content (fs/readFileSync file-path "utf8")]
        (println (marked/parse content)))
      (throw (js/Error. "No input file provided.")))
    (catch :default e
      (.error js/console (str "Error: " (.-message e)))
      (js/process.exit 1))))

(main *command-line-args*)
