rustyline icon indicating copy to clipboard operation
rustyline copied to clipboard

Support for arbitrary streams for input/output

Open slashrsm opened this issue 3 years ago • 9 comments

It seems that rustyline currently only supports standard input/output. Goose will accept connections via telnet and expose a command line interface, which allows users to control their load tests. We would like to use rustyline to improve the UX of the said command line, but we would need to be able to wire it into a TCP stream instead of stdin/stdout.

The idea of supporting arbitrary streams was already floated in #377. This approach would allow us to achieve what we want while also opening a lot of other possibilities for the library.

Is this something that would be considered? Are there any plans to do that already?

slashrsm avatar Jul 13 '21 07:07 slashrsm

Like https://github.com/jline/jline3/tree/master/remote-ssh/src/main/java/org/jline/builtins/ssh or https://github.com/prompt-toolkit/python-prompt-toolkit/tree/master/examples/ssh ?

gwenn avatar Jul 13 '21 17:07 gwenn

Yes, something like this.

slashrsm avatar Jul 13 '21 19:07 slashrsm

I have no idea how jline3 / python-prompt-toolkit support ssh / telnet session. Maybe only the Terminal implementation differs ?

gwenn avatar Jul 13 '21 20:07 gwenn

Possibly another implementation of the Term trait? Additionally to the Windows and Unix ones that we have already?

slashrsm avatar Jul 14 '21 06:07 slashrsm

In this case, we need a cargo feature to activate the ssh / telnet implementation.

gwenn avatar Jul 14 '21 06:07 gwenn

Agreed. Are you generally prepared to accept this feature if I give it a try?

slashrsm avatar Jul 14 '21 10:07 slashrsm

If only tty module is impacted and all new dependencies are optional except when this feature is activated, I am ok.

gwenn avatar Jul 14 '21 12:07 gwenn

OK, I will give it a try and see where it takes me. Thank you for the fast response!

slashrsm avatar Jul 14 '21 18:07 slashrsm

I implemented this here by adding a new variant to config::Behaviour that allows the user to specify file descriptors to use. Would you like me to file a PR?

m-mueller678 avatar Apr 02 '22 19:04 m-mueller678