Fork me on GitHub
#babashka
<
2020-05-29
>
jeroenvandijk09:05:36

Nice! What’s your idea behind it? Command line webscraping?

borkdude09:05:30

That could work yeah. Or just general UI testing using babashka

borkdude10:05:47

Funny enough, the featured article on wikipedia, which is scraped in the example, mentions "pod" 😉 https://en.wikipedia.org/wiki/Main_Page

jeroenvandijk10:05:31

Yesterday I came across Cucumber again. I was thinking what if this could work with Graalvm. Getting https://github.com/babashka/pod-babashka-etaoin to work would be an important part here

borkdude10:05:28

the main difference is that etaoin uses clj-http and this uses clj-http-lite

borkdude10:05:00

you can now use the filewatcher pod with bootleg, to re-compile your static website. and then use the etaoin pod to refresh a browser, to preview it.

🤯 1
🆒 1
martinklepsch13:05:06

babashka + bootleg with it’s new pod support are kind of blowing my mind, awesome stuff 👏 🚀

❤️ 3
Crispin13:05:20

who knows what pods are yet to come? 😁

jeroenvandijk13:05:38

I fear singularity

jeroenvandijk13:05:46

We should stop it here

Crispin14:05:11

Probably wise words... It does feel a bit like drugs.

martinklepsch13:05:42

When running a script babashka establishes some namespace bindings, which is great. When turning a script into a namespace it is kind of tedious to recreate the same bindings. I’m wondering if there could be an easier way to do that like (default-bindings!) or similar (that approach would unfortunately trip up clj-kondo I think)

borkdude13:05:21

Do you mean the namespace aliases?

borkdude13:05:00

These are only there in the user namespace. Once you use your own ns form, you lose them.

borkdude13:05:35

I suggest not to use the user aliases in a script: https://github.com/borkdude/babashka#explicit-requires

martinklepsch13:05:40

I see, that makes sense I guess. Guess I’ll have to write a babashka script that adds requires for the user aliases to a script file 😛

martinklepsch13:05:50

Mostly kidding but I guess that wouldn’t be too hard to do 😛

Darin Douglass13:05:51

I think the last point in that link is the most pertinent: > Writing compatible code gives you the option to run the same script with clojure having bb be a lightweight replacement for lein run is wonderful

martinklepsch13:05:13

Is there a way to access *input* in a namespace’s -main?

borkdude13:05:48

This var only exists in the user namespace, and again, is mostly there for one-liners. If you really need it, and can't use something like (edn/read *in*) or something, then you can use user/*input*.

martinklepsch13:05:37

Would you like a PR adding a one-line note about this here: https://github.com/borkdude/babashka#input-and-output-flags ?

martinklepsch13:05:20

Would this mean that -I/`-i` and -m are generally incompatible?

martinklepsch13:05:33

If so then a warning in this case might be better than adding to the docs?

borkdude13:05:38

-m is not necessarily incompatible with the input flags

borkdude13:05:01

but the suggestion is to use it for one-liners since it can be kind of tedious to read from stdin in them

borkdude13:05:39

it's a trade off you should make if you want to write Clojure-compatible scripts

borkdude13:05:51

since *input* is not available in normal Clojure

borkdude13:05:36

it does work with -main

borkdude17:05:27

The cljc.java-time library is now compatible with babashka! https://github.com/henryw374/cljc.java-time/issues/10#issuecomment-636101690

😎 4
🎉 3
joshmiller19:05:09

Hopefully I haven’t missed something obvious: What’s the recommended way to use bb to set environment variables in the shell it’s running from?

borkdude19:05:24

Can you give an example of what you want to do?

joshmiller19:05:22

I am writing a script to assume an AWS role, which involves trading a password and an MFA code for a session token. Then that session token is set as an environment variable in the shell while you do work with it.

borkdude19:05:39

processes cannot set environment variables for parent processes

borkdude19:05:03

I'm not sure if that's what you are trying to do, but it sounds like it?

joshmiller19:05:15

Yes, unfortunately, although I think in my case I have a workaround with aws configure. Thank you for your help!

joshmiller19:05:01

It would be nice to be able to set variables like you can using source in bash, although I’m not close to expert enough to understand how that would be done.

borkdude19:05:02

You can use clojure.java.shell/sh and pass :env variables for subcommands

borkdude19:05:35

but you can't set environment variables for the shell which calls babashka. unless you spit out some file and source that later

joshmiller19:05:59

Right, the latter seems like the workaround if you need to set up a separate environment

borkdude19:05:38

$ source /dev/stdin <<< $(bb -e '(println "FOO=3")')
$ echo $FOO
3

joshmiller20:05:18

Oh awesome, thank you