Last active
April 13, 2021 13:04
-
-
Save borkdude/abbd344734cb2607ecc74bb81f8866ee to your computer and use it in GitHub Desktop.
Babashka script that invokes -X clj-new/create
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;; Usage: | |
;; bb new.clj -t luminus -n foobar/baz --force +h2 | |
(require '[babashka.deps :as deps] | |
'[clojure.tools.cli :refer [parse-opts]]) | |
(def deps '{:deps {com.github.seancorfield/clj-new | |
{:mvn/version "1.1.297"}}}) | |
(def cli-opts [["-t" "--template NAME" "template"] | |
["-n" "--name NAME" "name"] | |
["-f" "--force" "force"]]) | |
(defn map->seq [m] | |
(reduce concat m)) | |
(let [{:keys [:options :arguments]} (parse-opts *command-line-args* cli-opts)] | |
(-> (deps/clojure (cond-> | |
(into ["-Sdeps" (str deps) "-X" "clj-new/create"] | |
(map->seq options)) | |
(seq arguments) (conj ":args" (str arguments))) | |
{:inherit true}) | |
deref | |
:exit | |
(System/exit))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment