in opennlp-morfologik-addon/src/main/java/opennlp/morfologik/cmdline/CLI.java [97:149]
public static void main(String[] args) {
if (args.length == 0) {
usage();
System.exit(0);
}
String[] toolArguments = new String[args.length - 1];
System.arraycopy(args, 1, toolArguments, 0, toolArguments.length);
String toolName = args[0];
//check for format
String formatName = StreamFactoryRegistry.DEFAULT_FORMAT;
int idx = toolName.indexOf(".");
if (-1 < idx) {
formatName = toolName.substring(idx + 1);
toolName = toolName.substring(0, idx);
}
CmdLineTool tool = toolLookupMap.get(toolName);
try {
if (null == tool) {
throw new TerminateToolException(1, "Tool " + toolName + " is not found.");
}
if ((0 == toolArguments.length && tool.hasParams()) ||
0 < toolArguments.length && "help".equals(toolArguments[0])) {
if (tool instanceof TypedCmdLineTool) {
logger.info(((TypedCmdLineTool) tool).getHelp(formatName));
} else if (tool instanceof BasicCmdLineTool) {
logger.info(tool.getHelp());
}
System.exit(0);
}
if (tool instanceof TypedCmdLineTool) {
((TypedCmdLineTool) tool).run(formatName, toolArguments);
} else if (tool instanceof BasicCmdLineTool) {
if (-1 == idx) {
((BasicCmdLineTool) tool).run(toolArguments);
} else {
throw new TerminateToolException(1, "Tool " + toolName + " does not support formats.");
}
} else {
throw new TerminateToolException(1, "Tool " + toolName + " is not supported.");
}
} catch (TerminateToolException e) {
logger.error(e.getLocalizedMessage(), e);
System.exit(e.getCode());
}
}