Action action = actionClass.newInstance();
CommandSession session = new DummyCommandSession();
ByteArrayOutputStream baos = new ByteArrayOutputStream();
PrintStream newout = new PrintStream(baos);
System.setOut(newout);
ActionPreparator preparator;
if (FORMAT_DOCBX.equals(format)) {
preparator = new DocbxPreparator(includeHelpOption);
} else {
preparator = new ConfPreparator(includeHelpOption);
}
preparator.prepare(action, session, Collections.<Object>singletonList("--help"));
newout.close();
baos.close();
return baos.toString();
} finally {
System.setOut(oldout);