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