dotfiles/bin/bbrep

17 lines
533 B
Text
Raw Permalink Normal View History

2025-04-27 21:57:27 +02:00
#!/usr/bin/env bb
;; Based on:
;; https://book.babashka.org/#_interacting_with_an_nrepl_server
(ns nrepl-client
(:require [bencode.core :as b]))
(defn nrepl-eval [port expr]
(println (clojure.string/trim expr))
(let [s (java.net.Socket. "localhost" port)
out (.getOutputStream s)
in (java.io.PushbackInputStream. (.getInputStream s))
_ (b/write-bencode out {"op" "eval" "code" expr})
bytes (get (b/read-bencode in) "value")]
(println ";;" (String. bytes))))
(nrepl-eval 1667 (slurp *in*))