From 599a6aedcf0066601393c33b3f2e9b1085626769 Mon Sep 17 00:00:00 2001 From: bluepython508 <16466646+bluepython508@users.noreply.github.com> Date: Thu, 12 Feb 2026 13:17:38 +0000 Subject: [PATCH] Extend repl to take arguments --- repl.janet | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/repl.janet b/repl.janet index 0ca9922..3b4b655 100644 --- a/repl.janet +++ b/repl.janet @@ -1,4 +1,25 @@ (import spork/netrepl) +(import spork/msg) -(defn main [exe] - (netrepl/client :unix (string (os/getenv "XDG_RUNTIME_DIR") "/censtablo-" (os/getenv "WAYLAND_DISPLAY")))) +(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))) +