[#353] set babashka.main property
This commit is contained in:
parent
e80fc1dee9
commit
3c2e17844d
3 changed files with 11 additions and 2 deletions
|
|
@ -318,6 +318,7 @@ Everything after that is bound to *command-line-args*."))
|
||||||
:verbose? :classpath
|
:verbose? :classpath
|
||||||
:main :uberscript] :as _opts}
|
:main :uberscript] :as _opts}
|
||||||
(parse-opts args)
|
(parse-opts args)
|
||||||
|
_ (when main (System/setProperty "babashka.main" main))
|
||||||
read-next (fn [*in*]
|
read-next (fn [*in*]
|
||||||
(if (pipe-signal-received?)
|
(if (pipe-signal-received?)
|
||||||
::EOF
|
::EOF
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,4 @@
|
||||||
|
(ns my.main2)
|
||||||
|
|
||||||
|
(defn -main [& _args]
|
||||||
|
(System/getProperty "babashka.main"))
|
||||||
|
|
@ -3,7 +3,8 @@
|
||||||
[babashka.test-utils :as tu]
|
[babashka.test-utils :as tu]
|
||||||
[clojure.edn :as edn]
|
[clojure.edn :as edn]
|
||||||
[clojure.java.io :as io]
|
[clojure.java.io :as io]
|
||||||
[clojure.test :as t :refer [deftest is]]))
|
[clojure.test :as t :refer [deftest is testing]]
|
||||||
|
[clojure.string :as str]))
|
||||||
|
|
||||||
(defn bb [input & args]
|
(defn bb [input & args]
|
||||||
(edn/read-string (apply tu/bb (when (some? input) (str input)) (map str args))))
|
(edn/read-string (apply tu/bb (when (some? input) (str input)) (map str args))))
|
||||||
|
|
@ -28,7 +29,10 @@
|
||||||
|
|
||||||
(deftest main-test
|
(deftest main-test
|
||||||
(is (= "(\"1\" \"2\" \"3\" \"4\")\n"
|
(is (= "(\"1\" \"2\" \"3\" \"4\")\n"
|
||||||
(tu/bb nil "--classpath" "test-resources/babashka/src_for_classpath_test" "-m" "my.main" "1" "2" "3" "4"))))
|
(tu/bb nil "--classpath" "test-resources/babashka/src_for_classpath_test" "-m" "my.main" "1" "2" "3" "4")))
|
||||||
|
(testing "system property"
|
||||||
|
(is (= "\"my.main2\""
|
||||||
|
(str/trim (tu/bb nil "--classpath" "test-resources/babashka/src_for_classpath_test" "-m" "my.main2"))))))
|
||||||
|
|
||||||
(deftest uberscript-test
|
(deftest uberscript-test
|
||||||
(let [tmp-file (java.io.File/createTempFile "uberscript" ".clj")]
|
(let [tmp-file (java.io.File/createTempFile "uberscript" ".clj")]
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue