*/
public static void main(String[] args) throws Exception
{
SchemaTool tool = new SchemaTool();
CommandLine cmd = new CommandLine();
cmd.addOption("create", "create", null, LOCALISER.msg(false, "014026"));
cmd.addOption("delete", "delete", null, LOCALISER.msg(false, "014027"));
cmd.addOption("validate", "validate", null, LOCALISER.msg(false, "014028"));
cmd.addOption("dbinfo", "dbinfo", null, LOCALISER.msg(false, "014029"));
cmd.addOption("schemainfo", "schemainfo", null, LOCALISER.msg(false, "014030"));
cmd.addOption("help", "help", null, LOCALISER.msg(false, "014033"));
cmd.addOption("ddlFile", "ddlFile", "ddlFile", LOCALISER.msg(false, "014031"));
cmd.addOption("completeDdl", "completeDdl", null, LOCALISER.msg(false, "014032"));
cmd.addOption("includeAutoStart", "includeAutoStart", null, "Include Auto-Start Mechanisms");
cmd.addOption("api", "api", "api", "API Adapter (JDO, JPA, etc)");
cmd.addOption("v", "verbose", null, "verbose output");
cmd.addOption("pu", "persistenceUnit", "<persistence-unit>",
"name of the persistence unit to handle the schema for");
cmd.addOption("props", "properties", "props", "path to a properties file");
cmd.parse(args);
// Remaining command line args are filenames (class files, metadata files)
String[] filenames = cmd.getDefaultArgs();
if (cmd.hasOption("api"))
{
tool.setApi(cmd.getOptionArg("api"));
}
// Determine the mode of operation required
String msg = null;
int mode = SCHEMATOOL_CREATE_MODE;
if (cmd.hasOption("create"))
{
mode = SCHEMATOOL_CREATE_MODE;
msg = LOCALISER.msg(false, "014000");
}
else if (cmd.hasOption("delete"))
{
mode = SCHEMATOOL_DELETE_MODE;
msg = LOCALISER.msg(false, "014001");
}
else if (cmd.hasOption("validate"))
{
mode = SCHEMATOOL_VALIDATE_MODE;
msg = LOCALISER.msg(false, "014002");
}
else if (cmd.hasOption("dbinfo"))
{
mode = SCHEMATOOL_DATABASE_INFO_MODE;
msg = LOCALISER.msg(false, "014003");
}
else if (cmd.hasOption("schemainfo"))
{
mode = SCHEMATOOL_SCHEMA_INFO_MODE;
msg = LOCALISER.msg(false, "014004");
}
else if (cmd.hasOption("help"))
{
System.out.println(LOCALISER.msg(false, "014023"));
System.out.println(LOCALISER.msg(false, "014024"));
System.out.println(LOCALISER.msg(false, "014025"));
System.out.println(cmd.toString());
System.out.println(LOCALISER.msg(false, "014034"));
System.out.println(LOCALISER.msg(false, "014035"));
System.exit(0);
}
LOGGER.info(msg);
System.out.println(msg);
// Extract the selected options
String propsFileName = null;
String persistenceUnitName = null;
if (cmd.hasOption("ddlFile"))
{
tool.setDdlFile(cmd.getOptionArg("ddlFile"));
}
if (cmd.hasOption("completeDdl"))
{
tool.setCompleteDdl(true);
}
if (cmd.hasOption("includeAutoStart"))
{
tool.setIncludeAutoStart(true);
}
if (cmd.hasOption("v"))
{
tool.setVerbose(true);
}
if (cmd.hasOption("pu"))
{
persistenceUnitName = cmd.getOptionArg("pu");
}
if (cmd.hasOption("props"))
{
propsFileName = cmd.getOptionArg("props");
}
// Classpath
msg = LOCALISER.msg(false, "014005");
LOGGER.info(msg);