/** * Prints the usage of CLI. * * @param mgr Command Manager object. * @throws CLIException if usage text cannot be presented. */ public void format(CommandManager mgr) throws CLIException { StringBuffer buff = new StringBuffer(); buff.append("\n\n"); formatUsage(mgr, buff); formatGlobalOptions(mgr, buff); formatSubcmds(mgr, buff); mgr.getOutputWriter().printlnMessage(buff.toString()); }
private static void dumpToOutput(CommandManager mgr, String msg, Throwable t) { if (mgr.isDebugOn()) { IOutput writer = mgr.getOutputWriter(); writer.printlnMessage(msg); if (t != null) { writer.printlnMessage(getStackTrace(t)); } } }
/** * Prints the usage of sub command. * * @param mgr Command Manager object. * @param cmd Sub command object. * @throws CLIException if usage text cannot be presented. */ public void format(CommandManager mgr, SubCommand cmd) throws CLIException { StringBuffer buff = new StringBuffer(); buff.append("\n\n"); ResourceBundle rb = mgr.getResourceBundle(); String commandName = mgr.getCommandName(); Object[] params = { commandName, cmd.getName(), rb.getString("USAGE_OPTIONS"), rb.getString("USAGE_GLOBAL_OPTIONS"), cmd.getDescription() }; buff.append(MessageFormat.format(CLIConstants.USAGE_SUBCMD_LONG_FORMAT, params)); buff.append("\n"); formatUsage(mgr, buff, cmd); formatGlobalOptions(mgr, buff); formatOptions(mgr, buff, cmd); mgr.getOutputWriter().printlnMessage(buff.toString()); }