String commandSuffix = FORMAT_DOCBX.equals(format) ? "xml" : "conf";
for (Class<?> clazz : classes) {
try {
Action action = (Action) clazz.newInstance();
ActionMetaData meta = new ActionMetaDataFactory().create(action.getClass());
Command cmd = meta.getCommand();
// skip the *-help command
if (cmd.scope().equals("*")) continue;
File output = new File(targetFolder, cmd.scope() + "-" + cmd.name() + "." + commandSuffix);
FileOutputStream outStream = new FileOutputStream(output);
PrintStream out = new PrintStream(outStream);
helpPrinter.printHelp(action, meta, out, includeHelpOption);
out.close();
outStream.close();
Set<String> cmds = commands.get(cmd.scope());
if (cmds == null) {
cmds = new TreeSet<String>();
commands.put(cmd.scope(), cmds);
}
cmds.add(cmd.name());
getLog().info("Found command: " + cmd.scope() + ":" + cmd.name());
} catch (Exception e) {
getLog().warn("Unable to write help for " + clazz.getName(), e);
}
}