Hi

It looks good, but compatibility may require some testing. For example, various 
versions of Windows.

Xuan Wang

________________________________
发件人: Christofer Dutz <[email protected]>
发送时间: 2024年1月10日 17:59
收件人: [email protected] <[email protected]>
主题: [DISCUSS] Refactor the CLI to allow passing in STDIN, STDOUT and STDERR?

Hi all,

I would love to be able to provide a Web-Based CLI. Usually, this sort of thing 
works by forwarding stdin, stdout and stderr to a remote client. I’m working on 
building a Web CLI for IoTDB, which I could integrate into a browser 
application.

I could do this by globally redirecting System.stdout … but in that case I’d be 
forwarding also Log output (if that’s logged to STDOUT) … so I would love to 
refactor the CLI to allow passing in explicit streams for all of these and to 
simply have the “main” method initialize these:

public static void main(String[] args) throws ClassNotFoundException, 
IOException {
  InputStream in = System.in;
  PrintStream out = System.out;
  PrintStream err = System.err;
  mainInternal(args, in, out, err);
}

public static void mainInternal(String[] args, InputStream in, PrintStream out, 
PrintStream err) throws ClassNotFoundException, IOException {

In that case I could call mainInternal (or whatever we name it) and pass in 
dedicated streams, which I redirect to the browser.

In that case I we would need to refactor all of the usages of System.out, 
System.in etc to use these passed along streams instead.

What do you folks think?

Chris

Reply via email to