carve.clj 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. #!/usr/bin/env bb
  2. ;; This file is copied from
  3. ;; https://github.com/borkdude/carve/blob/df552797a198b6701fb2d92390fce7c59205ea77/carve.clj
  4. ;; and thus this file is under the same EPL license.
  5. ;; The script is modified to run latest clj-kondo and carve versions and to add
  6. ;; a more friendly commandline interface through -main
  7. (require '[babashka.pods :as pods])
  8. (pods/load-pod 'clj-kondo/clj-kondo "2022.02.09")
  9. (require '[pod.borkdude.clj-kondo :as clj-kondo])
  10. ;; define clj-kondo.core ns which is used by carve
  11. (intern (create-ns 'clj-kondo.core) 'run! clj-kondo/run!)
  12. (require '[babashka.deps :as deps])
  13. (deps/add-deps '{:deps {borkdude/carve ;; {:local/root "."}
  14. {:git/url "https://github.com/borkdude/carve"
  15. :git/sha "df552797a198b6701fb2d92390fce7c59205ea77"}
  16. borkdude/spartan.spec {:git/url "https://github.com/borkdude/spartan.spec"
  17. :sha "12947185b4f8b8ff8ee3bc0f19c98dbde54d4c90"}}})
  18. (require '[spartan.spec]) ;; defines clojure.spec
  19. (with-out-str ;; silence warnings about spartan.spec + with-gen
  20. (binding [*err* *out*]
  21. (require '[carve.api :as carve])))
  22. ;; again to make clj-kondo happy
  23. (require '[carve.main])
  24. (require '[clojure.edn :as edn])
  25. (defn -main
  26. "Wrapper around carve.main that defaults to .carve/config.edn and merges
  27. in an optional string of options"
  28. [args]
  29. (let [default-opts (slurp ".carve/config.edn")
  30. opts (if-let [more-opts (first args)]
  31. (pr-str (merge (select-keys (edn/read-string default-opts) [:paths :api-namespaces])
  32. (edn/read-string more-opts)))
  33. default-opts)]
  34. (apply carve.main/-main ["--opts" opts])))
  35. (-main *command-line-args*)