-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"}
|
||||
insn/insn {:mvn/version "0.5.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
|
||||
{:main-opts ["-m" "babashka.main"]}
|
||||
:profile
|
||||
|
|
|
|||
|
|
@ -32,7 +32,7 @@
|
|||
[com.github.clj-easy/graal-build-time "0.1.0"]
|
||||
[rewrite-clj/rewrite-clj "1.0.699-alpha"]
|
||||
[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"]]
|
||||
:metabom {:jar-name "metabom.jar"}
|
||||
:profiles {:feature/xml {:source-paths ["feature-xml"]
|
||||
|
|
|
|||
|
|
@ -7,3 +7,14 @@
|
|||
|
||||
(def cli-namespace
|
||||
(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))
|
||||
(nthrest options 2)
|
||||
(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")
|
||||
(parse-run-opts opts-map (next options))
|
||||
("--tasks")
|
||||
|
|
@ -751,11 +757,13 @@ Use bb run --help to show this help output.
|
|||
:main :uberscript :describe?
|
||||
:jar :uberjar :clojure
|
||||
:doc :run :list-tasks
|
||||
:print-deps :prepare]}
|
||||
:print-deps :prepare]
|
||||
exec-fn :exec}
|
||||
cli-opts
|
||||
_ (when debug (vreset! common/debug true))
|
||||
_ (do ;; set properties
|
||||
(when main (System/setProperty "babashka.main" main))
|
||||
;; TODO: what about exec here?
|
||||
(System/setProperty "babashka.version" version))
|
||||
read-next (fn [*in*]
|
||||
(if (pipe-signal-received?)
|
||||
|
|
@ -865,6 +873,11 @@ Use bb run --help to show this help output.
|
|||
"-main")]
|
||||
[[(format "(ns user (:require [%1$s])) (apply %1$s/%2$s *command-line-args*)"
|
||||
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)
|
||||
[(print-run-help) 0]
|
||||
(do
|
||||
|
|
@ -1008,10 +1021,10 @@ Use bb run --help to show this help output.
|
|||
|
||||
(defn load-edn [string]
|
||||
(try (edn/read-string string)
|
||||
(catch java.lang.RuntimeException e
|
||||
(if (re-find #"No dispatch macro for: \"" (.getMessage e))
|
||||
(throw (ex-info "Invalid regex literal found in EDN config, use re-pattern instead" {}))
|
||||
(throw e)))))
|
||||
(catch java.lang.RuntimeException e
|
||||
(if (re-find #"No dispatch macro for: \"" (.getMessage e))
|
||||
(throw (ex-info "Invalid regex literal found in EDN config, use re-pattern instead" {}))
|
||||
(throw e)))))
|
||||
|
||||
(defn main [& args]
|
||||
(let [[args global-opts] (parse-global-opts args)
|
||||
|
|
|
|||
Loading…
Reference in a new issue