try {
String help = new HelpPrinter(clazz).printHelp(format);
Command cmd = (Command) clazz.getAnnotation(Command.class);
File output = null;
if (FORMAT_DOCBX.equals(format)) {
output = new File(targetFolder, cmd.scope() + "-" + cmd.name() + ".xml");
} else if (FORMAT_CONF.equals(format)) {
output = new File(targetFolder, cmd.scope() + "-" + cmd.name() + ".conf");
}
Writer writer = new OutputStreamWriter(new FileOutputStream(output));
writer.write(help);