Fork me on GitHub
#babashka
<
2021-03-16
>
onetom05:03:55

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

onetom05:03:37

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

onetom05:03:05

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

borkdude07:03:41

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

borkdude08:03:32

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

😃 12
babashka 15
borkdude10:03:17

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

❤️ 21
awesome 6
Célio15:03:27

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.

borkdude15:03:20

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élio15:03:54

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

borkdude16:03:07

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

borkdude16:03:30

maybe just :do as the delimiter again

borkdude16:03:08

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

borkdude16:03:20

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

borkdude17:03:13

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

mike_ananev17:03:30

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

borkdude18:03:09

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

borkdude18:03:54

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

borkdude18:03:39

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

borkdude18:03:34

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

borkdude18:03:27

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

borkdude18:03:13

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

borkdude18:03:45

Maybe this use case isn't common?