in freemarker-docgen-cli/src/main/java/org/freemarker/docgen/cli/Main.java [43:91]
public static void main(String[] args)
throws DocgenException, IOException, SAXException {
try {
if (args.length < 2) {
throw new CommandLineExitException(-1,
"Usage: java -jar docgen.jar <srcDir> <dstDir> [option1=value1 ...]");
}
Transform tr = new Transform();
tr.setSourceDirectory(new File(args[0]));
tr.setDestinationDirectory(new File(args[1]));
tr.setPrintProgress(true);
for (int i = 2; i < args.length; i++) {
String optStr = args[i];
final int equalsIdx = optStr.indexOf('=');
if (equalsIdx == -1) {
throw new CommandLineExitException(-1, "Options must be in name=value format");
}
String name = optStr.substring(0, equalsIdx).trim();
String value = optStr.substring(equalsIdx + 1).trim();
if (name.equals("offline")) {
tr.setOffline(parseBoolean(value));
} else if (name.equals("timeZone")) {
tr.setTimeZone(TimeZone.getTimeZone(value));
} else if (name.equals("generateEclipseToC")) {
tr.setGenerateEclipseToC(parseBoolean(value));
} else if (name.startsWith(CUSTOM_VARIABLES_DOT)) {
tr.addCustomVariableOverrides(
Collections.singletonMap(
name.substring(CUSTOM_VARIABLES_DOT.length()),
value));
} else if (name.startsWith(INSERTABLE_FILES_DOT)) {
tr.addInsertableFileOverrides(
Collections.singletonMap(
name.substring(INSERTABLE_FILES_DOT.length()),
value));
} else {
throw new CommandLineExitException(-1, "Unsupported option: " + name);
}
}
tr.execute();
} catch (CommandLineExitException e) {
p(e.getMessage().replaceAll("\n", System.lineSeparator()));
System.exit(e.getExitCode());
}
}