babashka/test-resources/bb.edn

63 lines
2.9 KiB
Clojure
Raw Permalink Normal View History

2021-03-19 11:14:04 +00:00
{:paths ["test-resources/bb-edn"] ;; no-brainer to support this
:deps {medley/medley {:mvn/version "1.3.0"}} ;; no-brainer to support this
;; here comes the part that is currently uncertain
2021-03-17 11:25:26 +00:00
:tasks {:count-files {:task/type :shell
:args ["bash" "-c" "ls | wc -l"]}
2021-03-17 15:59:33 +00:00
:bash {:task/type :babashka
:args [:invoke user/bash]}
2021-03-17 12:05:04 +00:00
:eval-plus {:task/type :babashka
2021-03-17 11:25:26 +00:00
:args [-e (apply + (map (fn [i]
(Integer/parseInt i))
*command-line-args*))]}
2021-03-17 15:36:25 +00:00
:describe {:task/type :babashka
:args [:clojure -Sdescribe]}
2021-03-17 13:40:21 +00:00
:do-bash {:task/type :babashka
:args [:do :bash "ls | wc -l"
:__ :eval-plus 1 2 3]}
2021-03-17 11:25:26 +00:00
:all {:task/type :babashka
2021-03-17 12:05:04 +00:00
:args [:do :count-files
:__ :bash "ls | wc -l"
:__ :eval-plus 1 2 3
2021-03-18 10:31:41 +00:00
:__ :describe]}
;;;;
2021-03-18 10:35:01 +00:00
:never-failing-shell
{:task/type :babashka
;; we are executing a shell task, yet we are continueing despite the error code
:args [-e (-> (do (deref (babashka.process/process ["ls" "foobar"] {:inherit true}))
(deref (babashka.process/process ["echo" "done"] {:inherit true}))
nil))]}
2021-03-18 10:31:41 +00:00
:print-hello {:task/type :babashka
:args [-e (println :hello)]}
2021-03-18 10:35:01 +00:00
:always-failing-shell
{:task/type :babashka
;; we are executing a shell task, yet we are continueing despite the error code
:args [-e (babashka.process/check (babashka.process/process ["ls" "foobar"] {:inherit true}))]}
:composed-never-failing {:task/type :babashka
:args [:do :never-failing-shell
:__ :print-hello]}
2021-03-18 10:31:41 +00:00
:composed-failing {:task/type :babashka
2021-03-18 10:35:01 +00:00
:args [:do :always-failing-shell
2021-03-18 10:31:41 +00:00
:__ :print-hello]}
2021-03-19 10:53:15 +00:00
,
2021-03-20 15:44:44 +00:00
;;;; help
:cool-task {:task/type :babashka
:args ["-e" "(+ 1 2 3)"]
:task/help "Usage: bb :cool-task
Sum up the numbers 1, 2 and 3."}
,
2021-03-19 10:53:15 +00:00
;;;; context (not implemented)
2021-03-19 11:14:04 +00:00
;; the problem with this is the DSL nature which is very opiniated and
;; maybe not so nice to learn for people who only want to write Clojure
2021-03-19 10:53:15 +00:00
:put-answer-in-ctx {:type/task :babashka
:args [:eval-plus 1 2 3]
:out [:answer]}
:print-answer {:type/task :babashka
:in {:sum [:answer]}
:args [-e (println $sum)]}
}
2021-03-18 10:31:41 +00:00
}