public static void main( String[] args ) throws Exception {
exit( new ToolRunner().execute( args ) );
}
public int execute(String...args) throws Exception {
JCommander commander = new JCommander(this);
commander.setProgramName(System.getProperty("app.name"));
// TODO (low) : this dirty solution has been introduced because it is not possible to
// parse arguments ( commander.parse() ) twice.
final File pluginsDirOption;
try {
pluginsDirOption = parsePluginDirOption(args);
} catch (Exception e) {
System.err.println(e.getMessage());
return 1;
}
if(pluginsDirOption != null) {
pluginsDir = pluginsDirOption;
}
// add all plugins first
final Iterator<Tool> tools = getToolsInClasspath();
while (tools.hasNext()) {
Tool tool = tools.next();
commander.addCommand(tool);
}
commander.parse(args);
Map<String, JCommander> commands = commander.getCommands();
String parsedCommand = commander.getParsedCommand();
if (printHelp) {
commander.usage();
return 0;
}
if (showVersion) {
printVersionInfo();
return 0;
}
if(parsedCommand == null) {
infoStream.println("A command must be specified.");
commander.usage();
return 1;
}
if (verbose) {
LogUtils.setVerboseLogging();