Fork me on GitHub
#nbb
<
2023-03-30
>
mkvlr08:03:47

if I want to conditionally start a repl, is there non-programmatic ways to do this (like for socket repl on the JVM using a system prop) or do I need to do this as part of my entry point?

borkdude08:03:36

only programmatic or via nbb repl / nrepl-server etc

mkvlr08:03:53

but nbb nrepl-server doesn’t compose with -m , correct?

borkdude08:03:06

nrepl-server does support an initial expression that you can execute, so you can compose that way

borkdude08:03:08

I thought it was also implemented for nrepl, but it looks like it's only there fore the console REPL: https://github.com/babashka/nbb/commit/6a1ff769df2afe0e642a57de9dda31145f722313 But it could be done for nrepl as well

mkvlr08:03:36

can I compose this with a -main fn?

borkdude08:03:45

what I mean is: you can programmatically start an nREPL server and do an :init expression in there, and e.g. execute a function that you would otherwise have executed with -m

borkdude08:03:46

but you may as well just start the nrepl server in your main entry point

mkvlr08:03:40

yeah, the main entry point is my test runner in that case

mkvlr08:03:05

don’t want to complect it with the repl concerns

borkdude08:03:11

but your test runner also has an API function, so you could programmatically start your test runner?

borkdude08:03:40

your test runner could also support an :init expression

borkdude08:03:51

too many choices ;)

borkdude08:03:22

I think programmatically using your test runner is the most flexible / composable option

👍 2
mkvlr08:03:38

since it’s not mine, not sure I want to change the api 🙃

borkdude08:03:39

let the user compose what they want, instead of guessing what the user might want to compose beforehand

borkdude08:03:28

@U5H74UNSF I have a fork of the cognitect test runner with some additional niceties.

borkdude08:03:22

it supports :only for invoking a namespace or var, similar to what lein has

borkdude08:03:34

also it prints that command when a test fails, so you can easily copy/paste it

borkdude08:03:41

and it prints what test it's running

borkdude08:03:46

basically all my favorite things from lein

borkdude09:03:26

I see I don't have the printing of the test in there, but it's what I do usually in user space

borkdude09:03:45

@U5H74UNSF What was your idea btw? The test runner runs the tests AND you have REPL, but then?

mkvlr09:03:04

yeah so have it start a repl when running in dev and exit on failure but pause and support to take over with interactive dev

mkvlr09:03:25

but yeah, a separate entry point is probably the way to go for this use case

👍 2