babashka / pods

Pods support for JVM and babashka

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Implement stdin op

borkdude opened this issue · comments

When evaluating something like:

(with-in-str "(assoc)"
  (clj-kondo/run! {:lint ["-"]}))

with the clj-kondo pod, this doesn't work as expected.

We need to implement a stdin op (https://nrepl.org/nrepl/ops.html#_stdin) as follows:

Whenever the pod needs a value from stdin, it will send a {"op" "stdin" "status" ["need-input"] "id" "..."} message to babashka (hopefully we can associate the right id?). Babashka will then slurp(?) stdin and respond with `{"op" "stdin" "status" ["done"] "id" "..." "stdin" "some-string"}.

Alternatives:

  • Have a special pods/with-in-str or pods/*in*
  • When invoking a pod function, we can have an optional {:stdin ...} options map that can accommodate more options for future use cases. Like {:callback ...} in case the user doesn't want to have a core.async channel back for async functions. The options map can carry some metadata {:babashka.pods/opts true} so we know not to pass it as an argument to the pod itself.:
(pods/load-pod ...)
(pod.foo/bar 1 2 3 (pods/opts {:stdin "hello" :callback #(...)}))