Fork me on GitHub
#babashka
<
2020-08-08
>
lread00:08:31

this is getting even more awesome!

3
nate18:08:00

Wow, babashka.process looks amazing

borkdude19:08:56

Thanks! The nice thing is, you can already use it today in bb, if you just copy paste the code or use it as a git dep. I do want to include it when it's more or less finished of course.

borkdude19:08:49

For early feedback, copy pasting the code and trying it out would be nice.

borkdude19:08:16

For the pipe case, it would be better if the defaults were streams instead of strings:

(-> (process ["ls"])
    (process ["grep" "README"]) :out)

borkdude19:08:43

but for the non-pipe case, strings might be handier so you don't have to call slurp

borkdude19:08:27

I guess one could always optimize if needed:

(-> (process ["ls"] {:out :stream})
    (process ["grep" "README"]) :out)

nate19:08:27

the ability for shell pipes to be converted into clojure thread macros is pretty 🤯

nate19:08:48

awesome to hear that this is a candidate for inclusion in babashka, seems like a perfect fit

Darin Douglass20:08:25

Maybe add a pipe-> macro which forces all processes to output streams except the last one? ¯\(ツ)

borkdude20:08:10

Yeah, I was also thinking something like that. Maybe defaulting to streams is less opinionated though, since that's what the Java API does as well

borkdude20:08:49

But maybe we should not optimize for the pipe case and just write a separate function for it like (pipe ["ls"] ["cat"] {:out :inherit}) so each process will pipe to the next, and you will give opts for the last one

Darin Douglass21:08:58

Hmm, I like that. Another idea: make pipe comp-like? It could return a fn that pipes input through the chain

borkdude21:08:57

Example pseudo-code?

Darin Douglass21:08:35

(defn greper (pipe [“grep” “foo"] [“tail” “-f”]))

Darin Douglass21:08:39

Or something like that

borkdude21:08:23

Speaking about grep and tail, I was just trying this: https://github.com/babashka/babashka.process/issues/8 And somehow it didn't work. Need to debug it some more. If someone feels like a nice puzzle. You do see output when you set :out and :err to :inherit in the first process.

borkdude21:08:21

For comparison, this does work:

(-> 
 (process ["yes"]
          {:out :stream
           :wait false
           :throw false
           :err :inherit})
 (process ["cat"] {:out :inherit
                   :err :inherit}))