@Override
public void printHelp(Action action, ActionMetaData actionMeta, PrintStream out, boolean includeHelpOption) {
Map<Option, Field> optionsMap = actionMeta.getOptions();
Map<Argument, Field> argsMap = actionMeta.getArguments();
Command command = action.getClass().getAnnotation(Command.class);
List<Argument> arguments = new ArrayList<Argument>(argsMap.keySet());
Collections.sort(arguments, new Comparator<Argument>() {
public int compare(Argument o1, Argument o2) {
return Integer.valueOf(o1.index()).compareTo(Integer.valueOf(o2.index()));
}
});
Set<Option> options = new HashSet<Option>(optionsMap.keySet());
if (includeHelpOption)
options.add(HelpOption.HELP);
out.println("<section>");
out.println(" <title>" + command.scope() + ":" + command.name() + "</title>");
out.println(" <section>");
out.println(" <title>Description</title>");
out.println(" <para>");
out.println(command.description());
out.println(" </para>");
out.println(" </section>");
StringBuffer syntax = new StringBuffer();
syntax.append(String.format("%s:%s", command.scope(), command.name()));
if (options.size() > 0) {
syntax.append(" [options]");
}
if (arguments.size() > 0) {
syntax.append(' ');