Fork me on GitHub
#babashka
<
2022-12-16
>
chaos08:12:24

Hi, what would be the canonical way to request an nrepl-server on a random port? bb nrepl-server 0 or bb nrepl-server :0? the first format is suggested by the bb book, though the second also provides some hint that we are referring to a port and not to an interface address; just wanted to ensure that the latter is also a supported format (it seems to work), thanks

borkdude08:12:29

Both are supposed to work

👍 1
skylize21:12:26

Can I set a task to pull its deps from a deps.edn alias?

borkdude21:12:46

There isn't an explicit API for this, although it's been asked before. But you can do it programmatically with (babashka.deps/add-deps (edn/parse-string (slurp "deps.edn")) {:aliases [:foo]})

skylize21:12:36

Can multiple tasks somehow share :org.babashka/cli coercions?

borkdude21:12:25

You can do this by placing those coercions on the namespace metadata and then exec functions from that namespace

skylize21:12:44

The :task code doesn't have a namespace. So I think you're saying I would need an external bb script that the task would call to parse the arguments?

borkdude21:12:15

Can you tell me how you would use those coercions in tasks? Maybe it's best to talk from there

skylize21:12:46

I'm back working on test running, and planning to try using cognitect/cljs test runner across the board. I need a separate task for each test environment, where each needs the arguments parsed to pass into cognitect.test-runner.api/test.

:task (exec 'cognitect.test-runner.api/test)
:org.babashka/cli {:coerce {:dirs []
                            :nses [:symbol]
                            :patterns []
                            :vars [:symbol]
                            :includes [:keyword]
                            :excludes [:keyword]
                            :only [:symbols]}}

skylize21:12:00

Actually... maybe I don't need that at all except for BB test. I guess for other enviroments I would be using (clojure ...). Can I just pass the arguments unchanged to that?

borkdude22:12:10

I've made a little wrapper like this, which is used for running clojure tests for babashka CLI itself: https://github.com/babashka/cli/blob/main/test/babashka/test_runner.clj

borkdude22:12:29

and then you can do:

clojure -M:test --vars foo.bar/baz 

borkdude22:12:59

or you can do:

clojure -X:test :vars '[foo.bar/baz]' 
which is the standard deps.edn syntax

borkdude22:12:14

and when called from tasks, this becomes: (clojure "-X:test" :vars '[foo.bar/baz]) since arguments are stringified

skylize22:12:51

thx. I'll take a look