/** * Print the specified text to the specified PrintWriter. * * @param pw The printWriter to write the help to * @param width The number of characters to display per line * @param text The text to be written to the PrintWriter */ public void printWrapped(PrintWriter pw, int width, String text) { printWrapped(pw, width, 0, text); }
/** * Print the cmdLineSyntax to the specified writer, using the * specified width. * * @param pw The printWriter to write the help to * @param width The number of characters per line for the usage statement. * @param cmdLineSyntax The usage statement. */ public void printUsage(PrintWriter pw, int width, String cmdLineSyntax) { int argPos = cmdLineSyntax.indexOf(' ') + 1; printWrapped(pw, width, getSyntaxPrefix().length() + argPos, getSyntaxPrefix() + cmdLineSyntax); }
@Override public void printUsage(final boolean verbose) { if (verbose) { final PrintWriter printWriter = new PrintWriter(output); final int width = 80; final HelpFormatter hf = new HelpFormatter(); hf.setWidth(width); commands.stream().forEach(c -> { hf.printWrapped(printWriter, width, "-------------------------------------------------------------------------------"); hf.printWrapped(printWriter, width, "COMMAND: " + getName() + " " + c.getName()); hf.printWrapped(printWriter, width, ""); hf.printWrapped(printWriter, width, "- " + c.getDescription()); hf.printWrapped(printWriter, width, ""); if (c.isReferencable()) { hf.printWrapped(printWriter, width, "PRODUCES BACK-REFERENCES"); hf.printWrapped(printWriter, width, ""); } }); printWriter.flush(); } else { commands.stream().forEach(c -> output.println("\t" + getName() + " " + c.getName())); } output.flush(); }
@Override public void printUsage(String errorMessage) { output.println(); if (errorMessage != null) { output.println("ERROR: " + errorMessage); output.println(); } final PrintWriter printWriter = new PrintWriter(output); final int width = 80; final HelpFormatter hf = new HelpFormatter(); hf.setWidth(width); hf.printWrapped(printWriter, width, getDescription()); hf.printWrapped(printWriter, width, ""); if (isReferencable()) { hf.printWrapped(printWriter, width, "PRODUCES BACK-REFERENCES"); hf.printWrapped(printWriter, width, ""); } hf.printHelp(printWriter, hf.getWidth(), getName(), null, getOptions(), hf.getLeftPadding(), hf.getDescPadding(), null, false); printWriter.println(); printWriter.flush(); }
printWrapped(pw, width, header); printWrapped(pw, width, footer);
printWrapped(pw, width, buff.toString().indexOf(' ') + 1, buff.toString());
/** * Prints the info about a command to the given print writer. * * @param command command to print info * @param pw where to print the info */ public static void printCommandInfo(Command command, PrintWriter pw) { String description = String.format("%s: %s", command.getCommandName(), command.getDescription()); int width = 80; try { width = TerminalFactory.get().getWidth(); } catch (Exception e) { // In case the terminal factory failed to decide terminal type, use default width } HELP_FORMATTER.printWrapped(pw, width, description); HELP_FORMATTER.printUsage(pw, width, command.getUsage()); if (command.getOptions().getOptions().size() > 0) { HELP_FORMATTER.printOptions(pw, width, command.getOptions(), HELP_FORMATTER.getLeftPadding(), HELP_FORMATTER.getDescPadding()); } }
/** * Print the specified text to the specified PrintWriter. * * @param pw The printWriter to write the help to * @param width The number of characters to display per line * @param text The text to be written to the PrintWriter */ public void printWrapped(PrintWriter pw, int width, String text) { printWrapped(pw, width, 0, text); }
/** * <p>Print the specified text to the specified PrintWriter.</p> * * @param pw The printWriter to write the help to * @param width The number of characters to display per line * @param text The text to be written to the PrintWriter */ public void printWrapped(PrintWriter pw, int width, String text) { printWrapped(pw, width, 0, text); }
/** * <p>Print the specified text to the specified PrintWriter.</p> * * @param pw The printWriter to write the help to * @param width The number of characters to display per line * @param text The text to be written to the PrintWriter */ public void printWrapped(PrintWriter pw, int width, String text) { printWrapped(pw, width, 0, text); }
/** * Print the specified text to the specified PrintWriter. * * @param pw The printWriter to write the help to * @param width The number of characters to display per line * @param text The text to be written to the PrintWriter */ public void printWrapped(PrintWriter pw, int width, String text) { printWrapped(pw, width, 0, text); }
/** * Print the specified text to the specified PrintWriter. * * @param pw The printWriter to write the help to * @param width The number of characters to display per line * @param text The text to be written to the PrintWriter */ public void printWrapped(PrintWriter pw, int width, String text) { printWrapped(pw, width, 0, text); }
/** * Print the cmdLineSyntax to the specified writer, using the * specified width. * * @param pw The printWriter to write the help to * @param width The number of characters per line for the usage statement. * @param cmdLineSyntax The usage statement. */ public void printUsage(PrintWriter pw, int width, String cmdLineSyntax) { int argPos = cmdLineSyntax.indexOf(' ') + 1; printWrapped(pw, width, defaultSyntaxPrefix.length() + argPos, defaultSyntaxPrefix + cmdLineSyntax); }
/** * <p>Print the cmdLineSyntax to the specified writer, using the * specified width.</p> * * @param pw The printWriter to write the help to * @param width The number of characters per line for the usage statement. * @param cmdLineSyntax The usage statement. */ public void printUsage(PrintWriter pw, int width, String cmdLineSyntax) { int argPos = cmdLineSyntax.indexOf(' ') + 1; printWrapped(pw, width, defaultSyntaxPrefix.length() + argPos, defaultSyntaxPrefix + cmdLineSyntax); }
/** * {@inheritDoc} */ @Override public void execute() throws CommandExecutionException { HelpFormatter formatter = new HelpFormatter(); String versionString = ResourceBundle.getBundle("options").getString("version_no"); formatter.printWrapped(writer, WRAP_WIDTH, versionString); }
private void pw(String message, int indent) { PrintWriter out = new PrintWriter(System.out); HelpFormatter formatter = new HelpFormatter(); formatter.printWrapped(out, 78, indent, message); out.flush(); }
private void pw(String message, int indent) { PrintWriter out = new PrintWriter(System.out); HelpFormatter formatter = new HelpFormatter(); formatter.printWrapped(out, 78, indent, message); out.flush(); }
/** * Print the cmdLineSyntax to the specified writer, using the * specified width. * * @param pw The printWriter to write the help to * @param width The number of characters per line for the usage statement. * @param cmdLineSyntax The usage statement. */ public void printUsage(PrintWriter pw, int width, String cmdLineSyntax) { int argPos = cmdLineSyntax.indexOf(' ') + 1; printWrapped(pw, width, getSyntaxPrefix().length() + argPos, getSyntaxPrefix() + cmdLineSyntax); }
/** * {@inheritDoc} */ @Override public void execute() { HelpFormatter formatter = new HelpFormatter(); formatter.printWrapped(writer, WRAP_WIDTH, getResource(I18N.BAD_OPTIONS)); formatter.printHelp(writer, WRAP_WIDTH, USAGE, getResource(I18N.OPTIONS_HEADER), options, 2, 2, null); } }
public static void printCommandUsage(String name, Options options, String usageFooter, PrintStream err) { HelpFormatter formatter = new HelpFormatter(); PrintWriter writer = new PrintWriter(err); formatter.printUsage(writer, 80, TOOL_NAME + " [OPTIONS] " + name, getOptionsWithHelp(options)); formatter.printWrapped(writer, 80, System.lineSeparator() + "Available options are:" + System.lineSeparator()); formatter.printOptions(writer, 80, getScriptOptions(), formatter.getLeftPadding(), formatter.getDescPadding()); formatter.printWrapped(writer, 80, System.lineSeparator() + "Available arguments are:" + System.lineSeparator()); formatter.printOptions(writer, 80, getOptionsWithHelp(options), formatter.getLeftPadding(), formatter.getDescPadding()); formatter.printWrapped(writer, 80, System.lineSeparator() + Objects.toString(usageFooter, "")); writer.flush(); }