Skip to content

Commit

Permalink
Missing config warning
Browse files Browse the repository at this point in the history
  • Loading branch information
PawelStroinski committed May 14, 2022
1 parent d937e2b commit 62044da
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion clj/src/cljd/build.clj
Original file line number Diff line number Diff line change
Expand Up @@ -308,6 +308,15 @@
(throw (Exception. (str "Unknown command: " command)))))
(list* options args)))))

(defn print-missing-config-warning [f-exists cmd]
(when-not (or f-exists
(contains? #{:help "init"} cmd))
(newline)
(println (title "WARNING: No cljd.edn file"))
(println "Did you forget to run the following command?")
(println (bright "clj -M -m cljd.build init <project_main_namespace>"))
(newline)))

(defn print-help [{:keys [doc options] :as spec}]
(when doc
(newline)
Expand Down Expand Up @@ -345,7 +354,8 @@

(defn -main [& args]
(let [f (java.io.File. (System/getProperty "user.dir") "cljd.edn")
config (if (.exists f)
f-exists (.exists f)
config (if f-exists
(with-open [rdr (-> f io/reader java.io.PushbackReader.)]
(edn/read rdr))
{})]
Expand All @@ -354,6 +364,7 @@
compiler/*lib-path*
(str (.getPath (java.io.File. (System/getProperty "user.dir") "lib")) "/")]
(let [[options cmd cmd-opts & args] (parse-args commands args)]
(print-missing-config-warning f-exists cmd)
(case cmd
:help (print-help commands)
"init"
Expand Down

0 comments on commit 62044da

Please sign in to comment.