Closed dundalek closed 5 years ago
This is not a difficult feature to add and would be very useful.
I propose that it work exactly like lumo. Copy pasting the relevant lines from lumo -h
:
-d, --dumb-terminal Disable line editing / VT100 terminal
control
-n opts, --socket-repl x Enable a socket REPL where x is port, IP:port
or JSON of the following form, where port is
required:
{"host": "localhost",
"port": 12345,
"accept": "some.namespaced.clojure/fn",
"args": ["args", {"for": "the accept fn"}]}
That would allow for both relevant scenarios:
@dundalek let me know if you are working on this. If not, I can do it.
@mnewt I imagine eventually we might need some structured protocol like nREPL/prepl but socket repl is a good start. I didn't start working on this so it is up for grabs.
OK, I'll work on it. I think socket repl is the standard for clojurescript for now. I think we should just implement that and worry about others once the clojurescript repl world stabilizes a bit.
I'm not aware of a clojurescript nREPL implementation. Is there one? prepl is interesting but still in development, and it will be interesting to see how the community uses it compared to unrepl.
Just a thought, is the idea to just launch lumo's socket repl? I think that it would be awesome to share implementation so that code would not be duplicated. Lumo accepts a function to it if you need to pre-parse the payloads.
@arichiardi I hope to do something like that. In keeping with the rest of closh, I would expect that we would re-use as much of lumo's socket repl code as possible. I looked over lumo's source and it seems straightforward but I don't know the exact entry point and haven't tried to implement it yet.
@arichiardi I haven't looked how lumo does it but if its true that your can pass a pre-process function to lumo and then launch it, that sounds like the simplest solution.
@mnewt You are right on both points, I don't know of a nREPL implementation in cljs either. It is doable but probably not the best investment of time. And I haven't been able to find any detailed description of prepl so I have no idea how it works.
Unrepl is a cool effort, but I am not convinced it has benefits to take over nREPL and adoption in community tooling seems to show that. I like the idea of wrapping around a socket repl. But if someone created a nREPL wrapper over socket repl, that would solve the main problem for me. Not sure what other benefits unrepl has.
So there is nRepl middleware but is Clojure specific.. it works for cljs but of course in very reduced fashion.
The main thing I would like to port to lumo is actually https://github.com/anmonteiro/lumo/issues/370.
That makes sense to me as first step.
@arichiardi Is lumo.socketRepl.open()
the entry point you had in mind?
I'm having trouble understanding how to load/call lumo's javascript modules from clojurescript (from inside lumo). Is the only way to first compile lumo to js and then require it? Can you give me any pointers?
Yes you got it right.
I was more thinking though that you can pass an accept function with the -n
parameter on the command line. Do you have a requirement to call the js function?
This param: https://github.com/anmonteiro/lumo/blob/master/src/js/cli.js#L92
Sorry line was missing
Add some REPL server support so we can have closh backend and connect to it with different frontend readline implementations like omnia or rebel-readline.
It would be also cool to explore possibility to run REPL via
clj
CLI tool.