-x
This commit is contained in:
parent
dc5b36bbe6
commit
1b3adaaf64
4 changed files with 31 additions and 7 deletions
2
deps.edn
2
deps.edn
|
|
@ -49,7 +49,7 @@
|
||||||
org.clojure/data.priority-map {:mvn/version "1.1.0"}
|
org.clojure/data.priority-map {:mvn/version "1.1.0"}
|
||||||
insn/insn {:mvn/version "0.5.2"}
|
insn/insn {:mvn/version "0.5.2"}
|
||||||
org.clojure/core.rrb-vector {:mvn/version "0.1.2"}
|
org.clojure/core.rrb-vector {:mvn/version "0.1.2"}
|
||||||
org.babashka/cli {:mvn/version "0.3.33"}}
|
org.babashka/cli {:mvn/version "0.3.34"}}
|
||||||
:aliases {:babashka/dev
|
:aliases {:babashka/dev
|
||||||
{:main-opts ["-m" "babashka.main"]}
|
{:main-opts ["-m" "babashka.main"]}
|
||||||
:profile
|
:profile
|
||||||
|
|
|
||||||
|
|
@ -32,7 +32,7 @@
|
||||||
[com.github.clj-easy/graal-build-time "0.1.0"]
|
[com.github.clj-easy/graal-build-time "0.1.0"]
|
||||||
[rewrite-clj/rewrite-clj "1.0.699-alpha"]
|
[rewrite-clj/rewrite-clj "1.0.699-alpha"]
|
||||||
[insn/insn "0.5.2"]
|
[insn/insn "0.5.2"]
|
||||||
[org.babashka/cli "0.3.33"]]
|
[org.babashka/cli "0.3.34"]]
|
||||||
:plugins [[org.kipz/lein-meta-bom "0.1.1"]]
|
:plugins [[org.kipz/lein-meta-bom "0.1.1"]]
|
||||||
:metabom {:jar-name "metabom.jar"}
|
:metabom {:jar-name "metabom.jar"}
|
||||||
:profiles {:feature/xml {:source-paths ["feature-xml"]
|
:profiles {:feature/xml {:source-paths ["feature-xml"]
|
||||||
|
|
|
||||||
|
|
@ -7,3 +7,14 @@
|
||||||
|
|
||||||
(def cli-namespace
|
(def cli-namespace
|
||||||
(sci/copy-ns babashka.cli cns))
|
(sci/copy-ns babashka.cli cns))
|
||||||
|
|
||||||
|
(defn exec-fn-snippet [ns var-name]
|
||||||
|
(format "
|
||||||
|
(require '%1$s)
|
||||||
|
(require '[babashka.cli])
|
||||||
|
(def ns-meta (meta (find-ns '%1$s)))
|
||||||
|
(def var-meta (meta (resolve '%1$s/%2$s)))
|
||||||
|
(def cli-opts (babashka.cli/merge-opts (:org.babashka/cli ns-meta) (:org.babashka/cli var-meta)))
|
||||||
|
(def opts (babashka.cli/parse-opts *command-line-args* cli-opts))
|
||||||
|
(%1$s/%2$s opts)"
|
||||||
|
ns var-name))
|
||||||
|
|
|
||||||
|
|
@ -645,6 +645,12 @@ Use bb run --help to show this help output.
|
||||||
:command-line-args (if (= "--" (second options))
|
:command-line-args (if (= "--" (second options))
|
||||||
(nthrest options 2)
|
(nthrest options 2)
|
||||||
(rest options))))
|
(rest options))))
|
||||||
|
("--exec", "-x",)
|
||||||
|
(let [options (next options)]
|
||||||
|
(assoc opts-map :exec (first options)
|
||||||
|
:command-line-args (if (= "--" (second options))
|
||||||
|
(nthrest options 2)
|
||||||
|
(rest options))))
|
||||||
("--run")
|
("--run")
|
||||||
(parse-run-opts opts-map (next options))
|
(parse-run-opts opts-map (next options))
|
||||||
("--tasks")
|
("--tasks")
|
||||||
|
|
@ -751,11 +757,13 @@ Use bb run --help to show this help output.
|
||||||
:main :uberscript :describe?
|
:main :uberscript :describe?
|
||||||
:jar :uberjar :clojure
|
:jar :uberjar :clojure
|
||||||
:doc :run :list-tasks
|
:doc :run :list-tasks
|
||||||
:print-deps :prepare]}
|
:print-deps :prepare]
|
||||||
|
exec-fn :exec}
|
||||||
cli-opts
|
cli-opts
|
||||||
_ (when debug (vreset! common/debug true))
|
_ (when debug (vreset! common/debug true))
|
||||||
_ (do ;; set properties
|
_ (do ;; set properties
|
||||||
(when main (System/setProperty "babashka.main" main))
|
(when main (System/setProperty "babashka.main" main))
|
||||||
|
;; TODO: what about exec here?
|
||||||
(System/setProperty "babashka.version" version))
|
(System/setProperty "babashka.version" version))
|
||||||
read-next (fn [*in*]
|
read-next (fn [*in*]
|
||||||
(if (pipe-signal-received?)
|
(if (pipe-signal-received?)
|
||||||
|
|
@ -865,6 +873,11 @@ Use bb run --help to show this help output.
|
||||||
"-main")]
|
"-main")]
|
||||||
[[(format "(ns user (:require [%1$s])) (apply %1$s/%2$s *command-line-args*)"
|
[[(format "(ns user (:require [%1$s])) (apply %1$s/%2$s *command-line-args*)"
|
||||||
ns var-name)] nil])
|
ns var-name)] nil])
|
||||||
|
exec-fn
|
||||||
|
(let [sym (symbol exec-fn)
|
||||||
|
ns (namespace sym)
|
||||||
|
var-name (name sym)]
|
||||||
|
[[(cli/exec-fn-snippet ns var-name)] nil])
|
||||||
run (if (:run-help cli-opts)
|
run (if (:run-help cli-opts)
|
||||||
[(print-run-help) 0]
|
[(print-run-help) 0]
|
||||||
(do
|
(do
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue