From ef4969e54c7197d95041872286314a3ad6aec964 Mon Sep 17 00:00:00 2001 From: Michiel Borkent Date: Tue, 16 Mar 2021 22:01:30 +0100 Subject: [PATCH] wip [skip ci] --- src/babashka/main.clj | 4 ++-- test-resources/bb.edn | 14 ++++++++------ test-resources/setup.clj | 16 ++++++++++++++++ 3 files changed, 26 insertions(+), 8 deletions(-) create mode 100644 test-resources/setup.clj diff --git a/src/babashka/main.clj b/src/babashka/main.clj index bd870ab7..70b2cbe1 100644 --- a/src/babashka/main.clj +++ b/src/babashka/main.clj @@ -471,11 +471,11 @@ Use -- to separate script command line args from bb command line args. (assoc opts-map :main (first options)))) (":do") (let [options (next options) - options (into [] (comp (partition-by #(= % ":do")) + options (into [] (comp (partition-by #(= % ":__")) (take-nth 2)) options) parsed (map parse-opts options)] - (assoc opts-map :do parsed)) + {:do parsed}) ;; fallback (if (some opts-map [:file :jar :socket-repl :expressions :main]) (assoc opts-map diff --git a/test-resources/bb.edn b/test-resources/bb.edn index d2312b74..75325057 100644 --- a/test-resources/bb.edn +++ b/test-resources/bb.edn @@ -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]} - :count-files {:babashka/process {:args [bash -c "ls | wc -l"] - ,,,}} - :all {:babashka/args [:do :eval-plus - :do :tree - :do :count-files]}}} + :all {:babashka/args [:do :eval-plus 1 2 3 + :__ :tree + :__ :bash "ls | wc -l"]}}} diff --git a/test-resources/setup.clj b/test-resources/setup.clj new file mode 100644 index 00000000..6d2f9840 --- /dev/null +++ b/test-resources/setup.clj @@ -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))) +