*
* @param args
* @throws Exception
*/
public static void main(final String[] args) throws Exception {
final ArgParser ap = new ArgParser("Persistit", args, ARG_TEMPLATE).strict();
if (ap.isUsageOnly()) {
return;
}
Persistit persistit = null;
final String propertiesFileName = ap.getStringValue("properties");
if (!propertiesFileName.isEmpty()) {
persistit = new Persistit();
persistit.setPropertiesFromFile(propertiesFileName);
persistit.initialize();
}
final String scriptName = ap.getStringValue("script");
final int cliport = ap.getIntValue("cliport");
if (cliport > -1 && !propertiesFileName.isEmpty()) {
throw new IllegalArgumentException("Specify only one: properties or cliport");
}
if (cliport > 1) {
System.out.printf("Starting a Persistit CLI server on port %d\n", cliport);
final Task task = CLI.cliserver(cliport);
task.runTask();
task.setPersistit(persistit);
} else if (!scriptName.isEmpty()) {
final BufferedReader reader = new BufferedReader(new FileReader(scriptName));
final PrintWriter writer = new PrintWriter(System.out);
CLI.runScript(persistit, reader, writer);
} else {
if (persistit == null) {
throw new IllegalArgumentException("Must specify a properties file");
}
final boolean gui = ap.isFlag('g');
final boolean icheck = ap.isFlag('i');
final boolean wait = ap.isFlag('w');
final boolean copy = ap.isFlag('c');
try {
if (gui) {
persistit.setupGUI(wait);
}