use of com.vaticle.typedb.core.server.parameters.ServerSubcommand in project grakn by graknlabs.
the class TypeDBServer method main.
public static void main(String[] args) {
try {
printASCIILogo();
CoreConfigParser configParser = new CoreConfigParser();
ArgsParser<ServerSubcommand> argsParser = new ArgsParser<ServerSubcommand>().subcommand(new ServerSubcommandParser.Server(configParser)).subcommand(new ServerSubcommandParser.Import()).subcommand(new ServerSubcommandParser.Export());
Optional<ServerSubcommand> subcmd = argsParser.parse(args);
if (subcmd.isEmpty()) {
LOG.error(UNRECOGNISED_CLI_COMMAND.message(String.join(" ", args)));
LOG.error(argsParser.usage());
System.exit(1);
} else {
if (subcmd.get().isServer()) {
ServerSubcommand.Server subcmdServer = subcmd.get().asServer();
if (subcmdServer.isHelp())
System.out.println(argsParser.help());
else if (subcmdServer.isVersion())
System.out.println("Version: " + Version.VERSION);
else
runServer(subcmdServer);
} else if (subcmd.get().isImport()) {
importData(subcmd.get().asImport());
} else if (subcmd.get().isExport()) {
exportData(subcmd.get().asExport());
} else
throw TypeDBException.of(ILLEGAL_STATE);
}
} catch (Exception e) {
if (e instanceof TypeDBException) {
LOG.error(e.getMessage());
} else {
LOG.error(e.getMessage(), e);
LOG.error(EXITED_WITH_ERROR.message());
}
System.exit(1);
}
System.exit(0);
}
Aggregations