ConsoleUI: Add a method to output an error to stderr

The error() method is added on the ConsoleUI abstract class so that it
can be used in both interactive and batch modes. This allows to output
messages that can be used to diagnose problems even when running a site
initialization in batch mode.

Change-Id: I62d6bae11b7b5f3850e3fac1e8b3da545e0a9575
This commit is contained in:
David Pursehouse
2016-11-30 15:58:33 +09:00
parent 9875c00ed9
commit e7b6cf1236

View File

@@ -87,6 +87,12 @@ public abstract class ConsoleUI {
/** Prompt the user for a password, returning the string; null if blank. */
public abstract String password(String fmt, Object... args);
/** Display an error message on the system stderr. */
public void error(String format, Object... args) {
System.err.println(String.format(format, args));
System.err.flush();
}
/** Prompt the user to make a choice from an enumeration's values. */
public abstract <T extends Enum<?>> T readEnum(T def, String fmt,
Object... args);