return doRunCommand(brjs, args);
}
private static int doRunCommand(BRJS brjs, String[] args) throws CommandOperationException
{
Logger logger = brjs.logger(UserCommandRunner.class);
try {
checkApplicationLibVersions(brjs, logger);
return brjs.runCommand(args);
}
catch (NoSuchCommandException e) {
if (e.getCommandName().length() > 0)
{
logger.println(e.getMessage());
logger.println("--------");
logger.println("");
}
return doRunCommand(brjs, new String[] {new HelpCommand().getCommandName() });
}
catch (CommandArgumentsException e) {
logger.println("Problem:");
logger.println(" " + e.getMessage());
logger.println("");
logger.println("Usage:");
logger.println(" brjs " + e.getCommand().getCommandName() + " " + e.getCommand().getCommandUsage());
}
catch (CommandOperationException e) {
logger.println("Error:");
logger.println(" " + e.getMessage());
if (e.getCause() != null) {
logger.println("");
logger.println("Caused By:");
logger.println(" " + e.getCause().getMessage());
}
logger.println("");
logger.println("Stack Trace:");
StringWriter stackTrace = new StringWriter();
e.printStackTrace(new PrintWriter(stackTrace));
logger.println(stackTrace.toString());
throw e;
}
return -1;
}