String[] subArgs;
if (args.length == 0) {
StringBuffer res = new StringBuffer();
Object[] fArgs = new Object[2];
PrintfFormat fmt;
String fmtStr;
int maxLen;
res.append(" " + this.getUsageShort());
res.append(".\n For further help on each subcommand, ");
res.append("type 'help ");
res.append(this.getCommandName() + " <subcommand>'\n\n");
maxLen = 0;
for (Iterator i=this.getHandlerNames().iterator(); i.hasNext();) {
String cmdName = (String)i.next();
if (cmdName.length() > maxLen)
maxLen = cmdName.length();
}
fmtStr = " %-" + (maxLen + 1) + "s %s";
fmt = new PrintfFormat(fmtStr);
for (Iterator i=this.getHandlerNames().iterator(); i.hasNext();) {
String cmdName = (String)i.next();
ShellCommandHandler sub = this.getSubHandler(cmdName);
fArgs[0] = cmdName + ":";
fArgs[1] = sub.getUsageShort();
res.append(fmt.sprintf(fArgs));
if (i.hasNext())
res.append("\n");
}
return res.toString();
}