package com.beust.jcommander.internal;

import com.beust.jcommander.ParameterException;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class DefaultConsole implements Console {

  public void print(String msg) {
    System.out.print(msg);
  }

  public void println(String msg) {
    System.out.println(msg);
  }

  public char[] readPassword(boolean echoInput) {
    try {
      // Do not close the readers since System.in should not be closed
      InputStreamReader isr = new InputStreamReader(System.in);
      BufferedReader in = new BufferedReader(isr);
      String result = in.readLine();
      return result.toCharArray();
    }
    catch (IOException e) {
      throw new ParameterException(e);
    }
  }

}

@@ -174,16 +174,44 @@
 mReader;
+%0Aimport java.io.PrintStream;
 %0A%0Apublic
@@ -252,16 +252,192 @@
 onsole %7B
+%0A  private final PrintStream target;%0A%0A  public DefaultConsole(PrintStream target) %7B%0A    this.target = target;%0A  %7D%0A%0A  public DefaultConsole() %7B%0A    this.target = System.out;%0A  %7D
 %0A%0A  publ
@@ -464,33 +464,29 @@
  msg) %7B%0A    
-System.ou
+targe
 t.print(msg)
@@ -532,25 +532,21 @@
 ) %7B%0A    
-System.ou
+targe
 t.printl

allow System.out to be replaced by something else (f.e. System.err)