wip [skip ci]
This commit is contained in:
parent
644634be1d
commit
1160f44d22
2 changed files with 10 additions and 11 deletions
|
|
@ -474,6 +474,13 @@ Use -- to separate script command line args from bb command line args.
|
||||||
options)
|
options)
|
||||||
parsed (map parse-opts options)]
|
parsed (map parse-opts options)]
|
||||||
{:do parsed})
|
{:do parsed})
|
||||||
|
(":invoke")
|
||||||
|
{:exec-src
|
||||||
|
(pr-str `(do (if-let [f (requiring-resolve (symbol (first *command-line-args*)))]
|
||||||
|
(apply f (rest *command-line-args*))
|
||||||
|
(throw (Exception. (str "Var not found: " (first *command-line-args*)
|
||||||
|
" " (babashka.classpath/get-classpath)))))))
|
||||||
|
:command-line-args (next options)}
|
||||||
;; 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
|
||||||
|
|
@ -517,15 +524,7 @@ Use -- to separate script command line args from bb command line args.
|
||||||
[nil
|
[nil
|
||||||
(-> (p/process args {:inherit true})
|
(-> (p/process args {:inherit true})
|
||||||
p/check
|
p/check
|
||||||
:exit)])})
|
:exit)])}))
|
||||||
:fn
|
|
||||||
(let [var (get task :var)
|
|
||||||
var-sym (symbol var)]
|
|
||||||
{:exec-src (pr-str `(do (if-let [f (requiring-resolve '~var-sym)]
|
|
||||||
(apply f *command-line-args*)
|
|
||||||
(throw (Exception. (str "Var not found: " '~var-sym
|
|
||||||
" " (babashka.classpath/get-classpath)))))))
|
|
||||||
:command-line-args command-line-args}))
|
|
||||||
(error (str "No such task: " task) 1))
|
(error (str "No such task: " task) 1))
|
||||||
(error (str "File does not exist: " task) 1)))
|
(error (str "File does not exist: " task) 1)))
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,8 @@
|
||||||
{:paths ["test-resources/bb-edn"]
|
{:paths ["test-resources/bb-edn"]
|
||||||
:tasks {:count-files {:task/type :shell
|
:tasks {:count-files {:task/type :shell
|
||||||
:args ["bash" "-c" "ls | wc -l"]}
|
:args ["bash" "-c" "ls | wc -l"]}
|
||||||
:bash {:task/type :fn
|
:bash {:task/type :babashka
|
||||||
:var user/bash}
|
:args [:invoke user/bash]}
|
||||||
:eval-plus {:task/type :babashka
|
:eval-plus {:task/type :babashka
|
||||||
:args [-e (apply + (map (fn [i]
|
:args [-e (apply + (map (fn [i]
|
||||||
(Integer/parseInt i))
|
(Integer/parseInt i))
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue