REPL loop.
synxroform opened this issue · 2 comments
Hello, I want to extend this console to something more like terminal. But I can't figure out how to spawn REPL process, currently I'm
doing ...
local proc, err = process.start(command, { cwd=opt.cwd, stdin = process.REDIRECT_DISCARD, timeout=process.WAIT_INFINITE })
local text = proc:read_stdout()
while proc:running() do
if text ~= nil then
push_output(text, opt)
end
coroutine.yield(0.1)
text = proc:read_stdout()
end
core.log("process is stopped")
but spawned process exit immediately after printing version information and >>> e.g for python it's a
Python 3.8.3 (tags/v3.8.3:6f8c832, May 13 2020, 22:20:19) [MSC v.1925 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>>
Googling for REPL and reproc doesn't help, only one issue but it's unclear is it fixed or not.
It is a little bit complicated but the problem is that with stdin = process.REDIRECT_DISCARD
we are closing stdin of the child process. We should keep it open with REDIRECT_PIPE I guess.
The following step would be to feed the child process stdin with the text you may type in the console but this is not trivial. I think currently you cannot type in the console.
Actually i can type in console. Now i'm playing with winpty as alternative to reproc. There are many things to figure out.