dude
This commit is contained in:
parent
d8cd25a84d
commit
ab3b4fa53a
2 changed files with 34 additions and 53 deletions
|
|
@ -171,14 +171,16 @@ Use -- to separate script command line args from bb command line args.
|
||||||
(let [main (if (simple-symbol? main)
|
(let [main (if (simple-symbol? main)
|
||||||
(symbol (str main) "-main")
|
(symbol (str main) "-main")
|
||||||
main)]
|
main)]
|
||||||
(if-let [doc (sci/eval-string* ctx (format "(some-> (requiring-resolve '%s) meta :doc)" main))]
|
(if (sci/eval-string* ctx (format "(when (requiring-resolve '%1$s)
|
||||||
[(println doc) 0]
|
(clojure.repl/doc %1$s) true)" main))
|
||||||
|
[nil 0]
|
||||||
[(print-error "No docstring found for task:" k) 1]))
|
[(print-error "No docstring found for task:" k) 1]))
|
||||||
[(print-error "No docstring found for task:" k) 1])))
|
[(print-error "No docstring found for task:" k) 1])))
|
||||||
[(print-error "Task does not exist:" k) 1]))
|
[(print-error "Task does not exist:" k) 1]))
|
||||||
(let [arg (if (str/includes? arg "/") arg (str "clojure.core/" arg))]
|
(let [arg (if (str/includes? arg "/") arg (str "clojure.core/" arg))]
|
||||||
(if-let [doc (sci/eval-string* ctx (format "(some-> (requiring-resolve '%s) meta :doc)" arg))]
|
(if (sci/eval-string* ctx (format "(when (requiring-resolve '%1$s)
|
||||||
[(println doc) 0]
|
(clojure.repl/doc %1$s) true)" arg))
|
||||||
|
[nil 0]
|
||||||
[(print-error "No docstring found for var:" arg) 1]))))
|
[(print-error "No docstring found for var:" arg) 1]))))
|
||||||
,)
|
,)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2,61 +2,40 @@
|
||||||
:deps {medley/medley {:mvn/version "1.3.0"}} ;; 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
|
;; here comes the part that is currently uncertain
|
||||||
:tasks {:count-files {:task/type :shell
|
:tasks {:count-files [shell "bash" "-c" "ls | wc -l"]
|
||||||
:args ["bash" "-c" "ls | wc -l"]}
|
:bash [babashka user/bash]
|
||||||
:bash {:task/type :babashka
|
:eval-plus [babashka -e (apply + (map (fn [i]
|
||||||
:args [:invoke user/bash]}
|
(Integer/parseInt i))
|
||||||
:eval-plus {:task/type :babashka
|
*command-line-args*))]
|
||||||
:args [-e (apply + (map (fn [i]
|
:describe [babashka clojure -Sdescribe]
|
||||||
(Integer/parseInt i))
|
:do-bash [do
|
||||||
*command-line-args*))]}
|
[:bash "ls | wc -l"]
|
||||||
:describe {:task/type :babashka
|
[:eval-plus 1 2 3]]
|
||||||
:args [:clojure -Sdescribe]}
|
:all [do
|
||||||
:do-bash {:task/type :babashka
|
[:count-files]
|
||||||
:args [:do :bash "ls | wc -l"
|
[:bash "ls | wc -l"]
|
||||||
:__ :eval-plus 1 2 3]}
|
[:eval-plus 1 2 3]
|
||||||
:all {:task/type :babashka
|
[:describe]]
|
||||||
:args [:do :count-files
|
|
||||||
:__ :bash "ls | wc -l"
|
|
||||||
:__ :eval-plus 1 2 3
|
|
||||||
:__ :describe]}
|
|
||||||
;;;;
|
;;;;
|
||||||
:never-failing-shell
|
:never-failing-shell
|
||||||
{:task/type :babashka
|
[babashka -e (-> (do (deref (babashka.process/process ["ls" "foobar"] {:inherit true}))
|
||||||
;; we are executing a shell task, yet we are continueing despite the error code
|
(deref (babashka.process/process ["echo" "done"] {:inherit true}))
|
||||||
:args [-e (-> (do (deref (babashka.process/process ["ls" "foobar"] {:inherit true}))
|
nil))]
|
||||||
(deref (babashka.process/process ["echo" "done"] {:inherit true}))
|
:print-hello [babashka -e (println :hello)]
|
||||||
nil))]}
|
:always-failing-shell [babashka -e (babashka.process/check (babashka.process/process ["ls" "foobar"] {:inherit true}))]
|
||||||
:print-hello {:task/type :babashka
|
:composed-never-failing [do
|
||||||
:args [-e (println :hello)]}
|
[:never-failing-shell]
|
||||||
|
[:print-hello]]
|
||||||
:always-failing-shell
|
:composed-failing [do
|
||||||
{:task/type :babashka
|
[:always-failing-shell]
|
||||||
;; we are executing a shell task, yet we are continueing despite the error code
|
[:print-hello]]
|
||||||
: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]}
|
|
||||||
:composed-failing {:task/type :babashka
|
|
||||||
:args [:do :always-failing-shell
|
|
||||||
:__ :print-hello]}
|
|
||||||
,
|
,
|
||||||
|
|
||||||
;;;; help
|
;;;; help
|
||||||
:cool-task {:task/type :babashka
|
:cool-task {:doc "Usage: bb :cool-task
|
||||||
:args ["-e" "(+ 1 2 3)"]
|
|
||||||
:task/help "Usage: bb :cool-task
|
|
||||||
|
|
||||||
Sum up the numbers 1, 2 and 3."}
|
Sum up the numbers 1, 2 and 3."
|
||||||
|
:task [babashka "-e" "(+ 1 2 3)"]}
|
||||||
,
|
,
|
||||||
;;;; context (not implemented)
|
|
||||||
;; 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
|
|
||||||
: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)]}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue