Files
censtablo/repl.janet
2026-02-12 13:17:52 +00:00

26 lines
710 B
Janet

(import spork/netrepl)
(import spork/msg)
(defn run-commands [sock args]
(with [stream (net/connect :unix sock)]
(def recv (msg/make-recv stream))
(def send (msg/make-send stream))
(send (string/format "\xFF%j" {:auto-flush false :name ""}))
(def prompt (recv))
(each arg args
(send (string "\xFF" arg))
(def [ok val] (-> (recv)
(parse)))
(if (string? val)
(print val)
(pp val))
(unless ok
(os/exit 1)))))
(defn main [exe & args]
(def sock (string (os/getenv "XDG_RUNTIME_DIR") "/censtablo-" (os/getenv "WAYLAND_DISPLAY")))
(if (empty? args)
(netrepl/client :unix sock)
(run-commands sock args)))