init: Refactor init to be small parts created through Guice
I was nuts when I wrote init. Making it all one giant program in a single class was simply insane. Instead we break it down into many smaller classes and use Guice to manage the creation, dependency injection, and control flow. Since init knew about most of the Files under the $site_path we put them all into a single immutable class called SitePaths and replace all references to these throughout the code base to use SitePaths and these well defined constants. init can now also import GerritServer.properties into the newer style gerrit.config and secure.config. This ensure the database settings are setup with the current defaults Change-Id: I4f5d8256497c1a97df35754dbe6193c78edde9e1 Signed-off-by: Shawn O. Pearce <sop@google.com>
This commit is contained in:
@@ -70,6 +70,18 @@ public abstract class ConsoleUI {
|
||||
/** Prompt the user for a string, suggesting a default, and returning choice. */
|
||||
public abstract String readString(String def, String fmt, Object... args);
|
||||
|
||||
/** Prompt the user for an integer value, suggesting a default. */
|
||||
public int readInt(int def, String fmt, Object... args) {
|
||||
for (;;) {
|
||||
String p = readString(String.valueOf(def), fmt, args);
|
||||
try {
|
||||
return Integer.parseInt(p.trim(), 10);
|
||||
} catch (NumberFormatException e) {
|
||||
System.err.println("error: Invalid integer format: " + p.trim());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/** Prompt the user for a password, returning the string; null if blank. */
|
||||
public abstract String password(String fmt, Object... args);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user