the funny thing is that this works in babashka. has anyone else encountered such an issue?
Babashka is more accepting here. Just rename to .cljc works if you also want to run it with Clojure
i tried it with clojure 1.10.1 and 1.10.3; both fails with the same error
on the #clojure channel the answer was to rename my source file to .cljc
that works, but now i wonder if i should name my babashka scripts with the .bb
extension or not... 😕
^ https://twitter.com/huahaiy/status/1371689142585753604 That's really exciting since we can now have our datalog database from babashka scripts directly :)
Playing around with a task runner idea for babashka:
borkdude@MBP2019 /tmp/test $ cat bb.edn
{:tasks {:eval-plus {:babashka/args ["-e" "(+ 1 2 3)"]}
:tree {:babashka/args [:clojure "-Stree"]}
:count-files {:babashka/process ["bash" "-c" "ls | wc -l"] }}}
borkdude@MBP2019 /tmp/test $ bb :eval-plus
6
borkdude@MBP2019 /tmp/test $ bb :count-files
1
borkdude@MBP2019 /tmp/test $ bb :tree | head
org.clojure/clojure 1.10.1
. org.clojure/spec.alpha 0.2.176
. org.clojure/core.specs.alpha 0.2.44
Welcome @huahaiy!
Is it possible to use symbols instead of keywords as keys? eg:
$ cat bb.edn
{:tasks {eval-plus {:babashka/args ["-e" "(+ 1 2 3)"]}
tree {:babashka/args [:clojure "-Stree"]}
count-files {:babashka/process ["bash" "-c" "ls | wc -l"] }}}
$ bb eval-plus
It looks neater.That's an opinion, but we can consider. I was hoping to avoid clashes with existing filenames. Could you maybe post this feedback here? https://github.com/babashka/babashka/issues/756
Sure
> I was hoping to avoid clashes with existing filenames. Ah! I get it now. Makes sense.
So I implemented some kind of lein do
constructions for this task runner idea.
The issue there is: should we do the same as lein: use comma as delimiter between tasks? Some other character (which does not conflict with the shell, such as &&
?
maybe just :do
as the delimiter again
$ bb :do '(prn :foo)' :do '(prn :bar)' :do :clojure
:foo
:bar
Clojure 1.10.2
user=> ^D
{:tasks {:eval-plus {:babashka/args [-e (+ 1 2 3)]}
:tree {:babashka/args [:clojure -Stree]}
:count-files {:babashka/process [bash -c "ls | wc -l"] }
:all {:babashka/args [:do :eval-plus
:do :tree
:do :count-files]}}}
$ bb :all
6
org.clojure/clojure 1.10.1
. org.clojure/spec.alpha 0.2.176
. org.clojure/core.specs.alpha 0.2.44
1
Maybe not the best and might conflict with CLI args called :do
, but suggestions welcome.
@borkdude It depends on the use case. But, in a common, when we put data into a string we ruin data. So, "should we do the same as lein: use comma as a delimiter between tasks?" I guess not. I propose to use some structured data in the command line too. Example is below (but may be I'm overengineering)
bb :do '[(prn :foo) (prn :bar) :clojure]' ;; or
bb '{:do [(prn :foo) (prn :bar) :clojure] :some-other-do-params :out-to-kafka}'
@mike1452 I want to allow people passing args as they normally do on the command line, only for multiple tasks at the same time (not as one quoted string).
I would consider :.
as the separator, but according the spec this isn't a valid keyword.
I wonder if I should allow this at all, how does make do this?
or maybe it should only be allowed in the bb.edn file, then it's easy:
[:do [:eval-plus] [:tree] [:count-files]]
but the idea of bb.edn file babashka/args
is that it acts as if you pass those from the command line...
Maybe it should be called differently: :all {:babashka/tasks [:eval-plus :tree :count-files]}
The issue I was trying to solve: what if :eval-plus
takes command line arguments
Maybe this use case isn't common?