babashka

https://github.com/babashka/babashka. Also see #sci, #nbb and #babashka-circleci-builds .
onetom 2021-03-16T05:10:55.000400Z

the funny thing is that this works in babashka. has anyone else encountered such an issue?

borkdude 2021-03-16T07:51:41.002100Z

Babashka is more accepting here. Just rename to .cljc works if you also want to run it with Clojure

onetom 2021-03-16T05:11:37.000600Z

i tried it with clojure 1.10.1 and 1.10.3; both fails with the same error

onetom 2021-03-16T05:24:05.000800Z

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... 😕

borkdude 2021-03-16T07:52:28.002300Z

❤️ 2
borkdude 2021-03-16T08:22:32.002800Z

^ https://twitter.com/huahaiy/status/1371689142585753604 That's really exciting since we can now have our datalog database from babashka scripts directly :)

5
😃 4
borkdude 2021-03-16T10:50:17.003900Z

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

2
❤️ 7
borkdude 2021-03-16T10:57:21.004100Z

borkdude 2021-03-16T14:57:02.007200Z

Welcome @huahaiy!

🙂 1
Célio 2021-03-16T15:20:27.007400Z

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.

borkdude 2021-03-16T15:23:20.007600Z

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

Célio 2021-03-16T15:25:23.008100Z

Sure

Célio 2021-03-16T15:27:54.008300Z

> I was hoping to avoid clashes with existing filenames. Ah! I get it now. Makes sense.

borkdude 2021-03-16T16:27:07.009700Z

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 &&?

borkdude 2021-03-16T16:32:30.010800Z

maybe just :do as the delimiter again

borkdude 2021-03-16T16:42:08.011600Z

$ bb :do '(prn :foo)' :do '(prn :bar)' :do :clojure
:foo
:bar
Clojure 1.10.2
user=> ^D

borkdude 2021-03-16T16:58:20.012Z

{: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

borkdude 2021-03-16T17:09:13.012500Z

Maybe not the best and might conflict with CLI args called :do, but suggestions welcome.

mike_ananev 2021-03-16T17:33:30.016900Z

@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}'

borkdude 2021-03-16T18:16:09.019Z

@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.

borkdude 2021-03-16T18:17:54.019400Z

I wonder if I should allow this at all, how does make do this?

borkdude 2021-03-16T18:18:39.020Z

or maybe it should only be allowed in the bb.edn file, then it's easy: [:do [:eval-plus] [:tree] [:count-files]]

borkdude 2021-03-16T18:19:34.020500Z

but the idea of bb.edn file babashka/args is that it acts as if you pass those from the command line...

borkdude 2021-03-16T18:20:27.021300Z

Maybe it should be called differently: :all {:babashka/tasks [:eval-plus :tree :count-files]}

borkdude 2021-03-16T18:21:13.022Z

The issue I was trying to solve: what if :eval-plus takes command line arguments

borkdude 2021-03-16T18:35:45.022200Z

Maybe this use case isn't common?