[#837] Add babashka.task System property

This commit is contained in:
Michiel Borkent 2021-05-13 11:53:28 +02:00
parent 5014012bd6
commit 7462d86afd
2 changed files with 8 additions and 2 deletions

View file

@ -745,8 +745,10 @@ Use bb run --help to show this help output.
ns var-name)] nil])
run (if (:run-help cli-opts)
[(print-run-help) 0]
(tasks/assemble-task run
(:parallel-tasks cli-opts)))
(do
(System/setProperty "babashka.task" (str run))
(tasks/assemble-task run
(:parallel-tasks cli-opts))))
file (try [[(read-file file)] nil]
(catch Exception e
(error-handler e {:expression expressions

View file

@ -192,6 +192,10 @@
(test-utils/with-config '{:tasks {b {:doc "Beautiful docstring"}}}
(let [s (test-utils/bb nil "doc" "b")]
(is (= "-------------------------\nb\nTask\nBeautiful docstring\n" s)))))
(testing "system property"
(test-utils/with-config '{:tasks {b (System/getProperty "babashka.task")}}
(let [s (bb "run" "--prn" "b")]
(is (= "b" s)))))
(deftest list-tasks-test
(test-utils/with-config {}