private void helpCommand(Context ctx) throws CommandException {
PrintWriter out = CommandHelper.getOutput(ctx);
String cmdName = (String) ctx.get(this.commandKey);
CommandLine desc = factory.getCommandLine(cmdName);
out.println(getString(bundle, "word.description") + ": ");
out.println(desc.getLocalizedDescription());
out.println();
// Usage
out.print(getString(bundle, "word.usage") + ":");
out.print(desc.getName() + " ");
// Arguments
Iterator iter = desc.getArguments().values().iterator();
while (iter.hasNext()) {
Argument arg = (Argument) iter.next();
out.print("<" + arg.getLocalizedArgName() + "> ");
}
// Options
iter = desc.getOptions().values().iterator();
while (iter.hasNext()) {
Option arg = (Option) iter.next();
out.print("-" + arg.getName() + " <" + arg.getLocalizedArgName()
+ "> ");
}
// flags
iter = desc.getFlags().values().iterator();
while (iter.hasNext()) {
Flag arg = (Flag) iter.next();
out.print("-" + arg.getName() + " ");
}
out.println();
// Alias
if (desc.getAlias().size() > 0) {
out.print(getString(bundle, "word.alias") + ":");
iter = desc.getAlias().iterator();
while (iter.hasNext()) {
out.print((String) iter.next() + " ");
}
out.println();
}
out.println();
// Arguments details
if (desc.getArguments().size() > 0) {
out.println("<" + getString(bundle, "word.arguments") + ">");
printParam(ctx, desc.getArguments().values());
}
// Options details
if (desc.getOptions().values().size() > 0) {
out.println();
out.println("<" + getString(bundle, "word.options") + ">");
printParam(ctx, desc.getOptions().values());
}
// flag details
if (desc.getFlags().values().size() > 0) {
out.println();
out.println("<" + getString(bundle, "word.flags") + ">");
printParam(ctx, desc.getFlags().values());
}
}