console icon indicating copy to clipboard operation
console copied to clipboard

Provide API to embed text console

Open stepancheg opened this issue 3 years ago • 1 comments
trafficstars

What problem are you trying to solve?

We have a binary deployed to servers.

It is not always trivial to get tokio-console binary to these servers.

We'd like to embed tokio-console in the binary. With command like:

our_binary --tokio-console

That binary should just launch tokio-console.

How should the problem be solved?

tokio-console crate to implement simple public API like:

fn run(args: &[&str]) { ... }

that API will do whatever tokio-console does: connects to the server, launch text UI, interpret keyboard input etc.

Any alternatives you've considered?

Do not embed tokio-console binary.

How would users interact with this feature?

No response

Would you like to work on this feature?

maybe

stepancheg avatar Oct 03 '22 20:10 stepancheg

It would definitely be possible to expose a library API to allow embedding the tokio-console TUI in another binary --- and probably fairly straightforward. We mostly haven't done this yet because there hasn't been any demand for it, and we haven't committed to an API surface for the console.

A simple interface taking a slice of arguments would be possible without making API commitments about the structure of the arguments themselves. We may also want to consider making the configuration structs that derive clap::Parser public, eventually, to support nicer programmatic configuration of an embedded console, but just taking a lsit of string arguments would be a safe starting point.

hawkw avatar Oct 03 '22 21:10 hawkw