MatrixCommand matrix = new MatrixCommand();
WeaveCommand weave = new WeaveCommand();
OptimizationCommand optimze = new OptimizationCommand();
EclipseProcessorCommand eclipse = new EclipseProcessorCommand();
JCommander parser = new JCommander(this);
parser.addCommand(MatrixCommand.COMMAND, matrix);
parser.addCommand(WeaveCommand.COMMAND, weave);
parser.addCommand(OptimizationCommand.COMMAND, optimze);
parser.addCommand(EclipseProcessorCommand.COMMAND, eclipse);
try {
parser.setProgramName(getJarName());
parser.parse(args);
if (help) {
parser.usage();
System.exit(0);
}
String command = parser.getParsedCommand();
if (MatrixCommand.COMMAND.equals(command)) {
matrix.execute();
} else if (WeaveCommand.COMMAND.equals(command)) {
weave.execute();
} else if (OptimizationCommand.COMMAND.equals(command)) {
optimze.execute();
} else if (EclipseProcessorCommand.COMMAND.equals(command)) {
eclipse.execute();
} else {
parser.usage();
System.exit(1);
}
} catch (ParameterException e) {
System.err.println(e.getMessage());
System.err.println();
parser.usage();
}
}