# open a janet repl in a different os window
repl:
	kitten @ launch --type=os-window --allow-remote-control --cwd=current --title=hx_repl:ludus --keep-focus
	kitten @ send-text -m "title:hx_repl:ludus" "janet -s\n"

# restart the repl server
restart:
	kitten @ send-text -m "title:hx_repl:ludus" "\04"
	kitten @ send-text -m "title:hx_repl:ludus" "janet -s\n"
	
# send what's selected to the repl and evaluate it
eval:
	sd "$" "\n" | sd "\n\n" "\n" | kitten @ send-text -m "title:hx_repl:ludus" --stdin

# get documentation for a symbol in janet/clojure
doc:
	sd "$" "\n" | sd "\n\n" "\n" | xargs -I _ echo "(doc " _ ")" | kitten @ send-text -m "title:hx_repl:ludus" --stdin

# publish to npm (did you build things first?)
publish:
	npm version patch
	npm publish

# build the ludus jimage
build:
	rm -f build/out.mjs
	rm -f build/out.wasm
	rm -f build/ludus.jimage
	janet -c src/ludus.janet build/ludus.jimage
	cd build && just build
	git commit -am "build"
