wip [skip ci]
This commit is contained in:
parent
e0dd41d631
commit
ef4969e54c
3 changed files with 26 additions and 8 deletions
|
|
@ -471,11 +471,11 @@ Use -- to separate script command line args from bb command line args.
|
||||||
(assoc opts-map :main (first options))))
|
(assoc opts-map :main (first options))))
|
||||||
(":do")
|
(":do")
|
||||||
(let [options (next options)
|
(let [options (next options)
|
||||||
options (into [] (comp (partition-by #(= % ":do"))
|
options (into [] (comp (partition-by #(= % ":__"))
|
||||||
(take-nth 2))
|
(take-nth 2))
|
||||||
options)
|
options)
|
||||||
parsed (map parse-opts options)]
|
parsed (map parse-opts options)]
|
||||||
(assoc opts-map :do parsed))
|
{:do parsed})
|
||||||
;; fallback
|
;; fallback
|
||||||
(if (some opts-map [:file :jar :socket-repl :expressions :main])
|
(if (some opts-map [:file :jar :socket-repl :expressions :main])
|
||||||
(assoc opts-map
|
(assoc opts-map
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,9 @@
|
||||||
{:tasks {:eval-plus {:babashka/args [-e (+ 1 2 3)]}
|
{:paths ["script"]
|
||||||
|
:tasks {:bash {:babashka/invoke {:fn cool-script/bash}}
|
||||||
|
:eval-plus {:babashka/args [-e (apply + (map (fn [i]
|
||||||
|
(Integer/parseInt i))
|
||||||
|
*command-line-args*))]}
|
||||||
:tree {:babashka/args [:clojure -Stree]}
|
:tree {:babashka/args [:clojure -Stree]}
|
||||||
:count-files {:babashka/process {:args [bash -c "ls | wc -l"]
|
:all {:babashka/args [:do :eval-plus 1 2 3
|
||||||
,,,}}
|
:__ :tree
|
||||||
:all {:babashka/args [:do :eval-plus
|
:__ :bash "ls | wc -l"]}}}
|
||||||
:do :tree
|
|
||||||
:do :count-files]}}}
|
|
||||||
|
|
|
||||||
16
test-resources/setup.clj
Normal file
16
test-resources/setup.clj
Normal file
|
|
@ -0,0 +1,16 @@
|
||||||
|
(defn eval-plus [& args]
|
||||||
|
(apply + (map (fn [i]
|
||||||
|
(Integer/parseInt i))
|
||||||
|
*command-line-args*)))
|
||||||
|
|
||||||
|
(defn tree []
|
||||||
|
(babashka.deps/clojure ["-Stree"]))
|
||||||
|
|
||||||
|
|
||||||
|
(defn all [& args]
|
||||||
|
(apply eval-plus args)
|
||||||
|
(tree))
|
||||||
|
|
||||||
|
(defn bash [& args]
|
||||||
|
(babashka.process/process (into ["bash"] args)))
|
||||||
|
|
||||||
Loading…
Reference in a new issue