commands.add(capitalized);
}
}
if (commands.size() == 0) {
log.error("Could not find any commands");
throw new CommandFailedException(-1);
}
} catch (Throwable e) {
log.debug("Was not loaded from a jar");
try {
// Get the location of this class
Class[] classes = getClasses("org.jboss.blacktie.btadmin.commands");
for (int i = 0; i < classes.length; i++) {
String commandName = classes[i].getName().substring(
classes[i].getName().lastIndexOf('.') + 1);
String firstLetter = commandName.substring(0, 1);
String remainder = commandName.substring(1);
String capitalized = firstLetter.toLowerCase() + remainder;
commands.add(capitalized);
}
} catch (Throwable e2) {
log.error("Could not find any commands");
throw new CommandFailedException(-1);
}
}
for (int i = 0; i < commands.size(); i++) {
if (command != null && !command.equals(commands.get(i))) {
continue;
}
try {
Command command = CommandHandler.loadCommand(commands.get(i));
log.info("Example usage: " + commands.get(i) + " "
+ command.getExampleUsage());
} catch (Exception e) {
log.error("Could not get help for command: " + commands.get(i),
e);
throw new CommandFailedException(-1);
}
}
}