Fork me on GitHub
#babashka
<
2021-10-07
>
nate03:10:50

when making a babashka pod, is it possible to provide docstrings for the exposed vars?

borkdude05:10:45

Not yet I think but it’s pretty easy to add this. Start adding doc keys to your vars and make an issue at the pods repo. Your also welcome to add this support but I’d be happy to do it

borkdude09:10:39

So here:

"vars" [{"name" "execute!"}

borkdude09:10:46

we could add "doc" "foobar"

borkdude09:10:42

and then we need to update this bit of code: https://github.com/babashka/pods/blob/de4c3610c9ef3879370d01b7202a9f3a9d056f6e/src/babashka/pods/impl.clj#L116 and several other places where this is used

nate17:10:15

Cool. Sounds good.

dabrazhe14:10:15

How can I script in bb to wait for one command to finish before starting the next one? I am issuing two aws cli commands and it appears that the first one triggers smth asynchronously and quits, and the next one starts before the actual change has been made.

Darin Douglass14:10:47

processes are derefable, so you’d just @(p/process ["aws" "some-command"])

Darin Douglass14:10:00

or you can use (p/check) which will throw if the process returns a bad exit-code

borkdude14:10:23

correct! and you can also use (babashka.tasks/shell "aws some-command") which will do all of the above - it accepts similar options to bb process but as the first argument

dabrazhe14:10:19

Thanks. Although I find bb /shell a bit cumbersome and hard to use in repl ..(

borkdude15:10:40

what's the reason?

dabrazhe15:10:13

The main being that if a shell command fails (eg error or not known) I only get the exception and the error is printed in the Calva output which I never use. The second reason is that parsing the output is rather cumbersome compared to java sh

borkdude15:10:22

@U96LS78UV there is also babashka.process/sh which is similar to clojure.java.shell/sh but tokenizes the arguments for you

borkdude15:10:50

(process/sh "aws some-command") ;;=> {:out ... :err ... :exit ...}

borkdude15:10:11

and it doesn't throw non non-zero

borkdude15:10:29

you can also use :continue true in shell to prevent throwing

borkdude15:10:56

process/sh is also blocking

borkdude15:10:10

so it seems that's what you need in this context

dabrazhe15:10:53

Thanks for the tip with continue! This works ok

((juxt :out :err) (shell {:continue true :out :string :err :string} "aws some-command" ))

dabrazhe15:10:16

but I guess I prefer the process now : )

dabrazhe15:10:22

But isn't clojure.java.shell/sh blocking as well??

borkdude15:10:54

yes. babashka.process/sh is like clojure.java.shell/sh (but it also tokenizes the string for you)

dabrazhe15:10:40

So why the hell clojure.java.shell/sh is not blocking the first aws command for me). This what I expected

borkdude15:10:45

it doesn't?

borkdude15:10:59

perhaps the aws command itself spawns another process and returns early?

dabrazhe18:10:09

I guess this is the case.