Java Code Examples for org.apache.commons.cli.HelpFormatter#printOptions()
The following examples show how to use
org.apache.commons.cli.HelpFormatter#printOptions() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Rdf2NeoCli.java From rdf2neo with GNU Lesser General Public License v3.0 | 7 votes |
private static void printUsage () { out.println (); out.println ( "\n\n *** Rdf2Neo, the RDF-to-Neo4j converter ***" ); out.println ( "\nConverts data from a Jena TDB database into Neo4J data" ); out.println ( "\nSyntax:" ); out.println ( "\n\trdf2neo.sh [options] <TDB path>" ); out.println ( "\nOptions:" ); HelpFormatter helpFormatter = new HelpFormatter (); PrintWriter pw = new PrintWriter ( out, true ); helpFormatter.printOptions ( pw, 100, getOptions (), 2, 4 ); out.println ( "\n\n" ); exitCode = 1; }
Example 2
Source File: Dumper.java From stetho with MIT License | 7 votes |
private void dumpUsage(PrintStream output) { final String cmdName = "dumpapp"; HelpFormatter formatter = new HelpFormatter(); output.println("Usage: " + cmdName + " [options] <plugin> [plugin-options]"); PrintWriter writer = new PrintWriter(output); try { formatter.printOptions( writer, formatter.getWidth(), mGlobalOptions.options, formatter.getLeftPadding(), formatter.getDescPadding()); } finally { writer.flush(); } }
Example 3
Source File: Dumper.java From weex with Apache License 2.0 | 6 votes |
private void dumpUsage(PrintStream output) { final String cmdName = "dumpapp"; HelpFormatter formatter = new HelpFormatter(); output.println("Usage: " + cmdName + " [options] <plugin> [plugin-options]"); PrintWriter writer = new PrintWriter(output); try { formatter.printOptions( writer, formatter.getWidth(), mGlobalOptions.options, formatter.getLeftPadding(), formatter.getDescPadding()); } finally { writer.flush(); } }
Example 4
Source File: Main.java From cloud-pubsub-samples-java with Apache License 2.0 | 6 votes |
/** * Prints out the usage to stderr. */ public static void help() { System.err.println("Usage: pubsub-sample.[sh|bat] [options] arguments"); HelpFormatter formatter = new HelpFormatter(); PrintWriter writer = new PrintWriter(System.err); formatter.printOptions(writer, 80, options, 2, 2); writer.print("Available arguments are:\n" + "PROJ list_topics\n" + "PROJ create_topic TOPIC\n" + "PROJ delete_topic TOPIC\n" + "PROJ list_subscriptions\n" + "PROJ create_subscription SUBSCRIPTION LINKED_TOPIC " + "[PUSH_ENDPOINT]\n" + "PROJ delete_subscription SUBSCRIPTION\n" + "PROJ connect_irc TOPIC SERVER CHANNEL\n" + "PROJ publish_message TOPIC MESSAGE\n" + "PROJ pull_messages SUBSCRIPTION\n" ); writer.close(); }
Example 5
Source File: Main.java From parquet-mr with Apache License 2.0 | 6 votes |
public static void showUsage(HelpFormatter format, PrintWriter err, String name, Command command) { Options options = mergeOptions(OPTIONS, command.getOptions()); String[] usage = command.getUsageDescription(); String ustr = name + " [option...]"; if (usage != null && usage.length >= 1) { ustr = ustr + " " + usage[0]; } format.printWrapped(err, WIDTH, name + ":\n" + command.getCommandDescription()); format.printUsage(err, WIDTH, ustr); format.printWrapped(err, WIDTH, LEFT_PAD, "where option is one of:"); format.printOptions(err, WIDTH, options, LEFT_PAD, DESC_PAD); if (usage != null && usage.length >= 2) { for (int i = 1; i < usage.length; ++i) { format.printWrapped(err, WIDTH, LEFT_PAD, usage[i]); } } }
Example 6
Source File: Main.java From parquet-tools with Apache License 2.0 | 6 votes |
public static void showUsage(HelpFormatter format, PrintWriter err, String name, Command command) { Options options = mergeOptions(OPTIONS, command.getOptions()); String[] usage = command.getUsageDescription(); String ustr = name + " [option...]"; if (usage != null && usage.length >= 1) { ustr = ustr + " " + usage[0]; } format.printUsage(err, WIDTH, ustr); format.printWrapped(err, WIDTH, LEFT_PAD, "where option is one of:"); format.printOptions(err, WIDTH, options, LEFT_PAD, DESC_PAD); if (usage != null && usage.length >= 2) { for (int i = 1; i < usage.length; ++i) { format.printWrapped(err, WIDTH, LEFT_PAD, usage[i]); } } }
Example 7
Source File: ApexCli.java From Bats with Apache License 2.0 | 5 votes |
@Override void printUsage(String cmd) { super.printUsage(cmd + ((options == null) ? "" : " [options]")); if (options != null) { System.out.println("Options:"); HelpFormatter formatter = new HelpFormatter(); PrintWriter pw = new PrintWriter(System.out); formatter.printOptions(pw, 80, options, 4, 4); pw.flush(); } }
Example 8
Source File: Commands.java From devops-cm-client with Apache License 2.0 | 5 votes |
static void handleHelpOption(String commandName, String header, String args, Options options) { String exitCodes = format( " %d The request completed successfully.\n" + " %d The request did not complete successfully and\n" + " no more specific return code as defined below applies.\n" + " %d Wrong credentials.\n" + " %d Intentionally used by --return-code option in order to\n" + " indicate 'false'. Only available for commands providing\n" + " the --return-code option.", ExitException.ExitCodes.OK, ExitException.ExitCodes.GENERIC_FAILURE, ExitException.ExitCodes.NOT_AUTHENTIFICATED, ExitException.ExitCodes.FALSE); String commonOpts; HelpFormatter formatter = new HelpFormatter(); try( StringWriter commonOptions = new StringWriter(); PrintWriter pw = new PrintWriter(commonOptions);) { formatter.printOptions(pw, formatter.getWidth(), Command.addOpts(new Options()), formatter.getLeftPadding(), formatter.getDescPadding()); commonOpts = commonOptions.toString(); } catch(IOException e) { throw new RuntimeException(e); } String footer = format("%nCOMMON OPTIONS:%n%s%nEXIT CODES%n%s", commonOpts, exitCodes); formatter.printHelp( format("<CMD> [COMMON_OPTIONS] %s [SUBCOMMAND_OPTIONS] %s%n%n", commandName, args != null ? args : ""), format("SUBCOMMAND OPTIONS:%n",header), options, footer); }
Example 9
Source File: ToolOptions.java From aliyun-maxcompute-data-collectors with Apache License 2.0 | 5 votes |
/** * Print the help to the specified PrintWriter, using the specified * help formatter. * @param formatter the HelpFormatter to use. * @param pw the PrintWriter to emit to. */ public void printHelp(HelpFormatter formatter, PrintWriter pw) { boolean first = true; for (RelatedOptions optGroup : optGroups) { if (!first) { pw.println(""); } pw.println(optGroup.getTitle() + ":"); formatter.printOptions(pw, formatter.getWidth(), optGroup, 0, 4); first = false; } }
Example 10
Source File: CommandLineFacade.java From titus-control-plane with Apache License 2.0 | 5 votes |
public void printHelp(String application) { PrintWriter writer = new PrintWriter(System.out); HelpFormatter formatter = new HelpFormatter(); writer.println(String.format("Usage: %s [params]", application)); writer.println(); writer.println("Options"); formatter.printOptions(writer, 128, options, 4, 4); writer.println(); writer.flush(); }
Example 11
Source File: CLI.java From titus-control-plane with Apache License 2.0 | 5 votes |
private void printHelp() { PrintWriter writer = new PrintWriter(System.out); HelpFormatter formatter = new HelpFormatter(); Options common = new Options(); appendDefaultOptions(common); Options connectivity = new Options(); appendConnectivityOptions(connectivity); writer.println("Usage: TitusCLI <cmd> -H <host> [-p <port>] [cmd options] [params]"); writer.println(); writer.println("Common options:"); formatter.printOptions(writer, 128, common, 4, 4); writer.println(); writer.println("Connectivity options:"); formatter.printOptions(writer, 128, connectivity, 4, 4); writer.println(); writer.println("Available commands:"); writer.println(); for (Map.Entry<String, CliCommand> entry : getCommands().entrySet()) { CliCommand cliCmd = entry.getValue(); writer.println(entry.getKey() + " (" + cliCmd.getDescription() + ')'); formatter.printOptions(writer, 128, cliCmd.getOptions(), 4, 4); } writer.flush(); }
Example 12
Source File: OptionsConsoleCommand.java From BiglyBT with GNU General Public License v2.0 | 5 votes |
@Override public void printHelpExtra(PrintStream out, List args) { HelpFormatter formatter = new HelpFormatter(); PrintWriter writer = new PrintWriter(out); writer.println("> -----"); writer.println(getCommandDescriptions()); // formatter.printHelp(writer, 80, getCommandDescriptions(), ">>>", getOptions(), 4, 4, ">>>", true); formatter.printOptions(writer, 80, getOptions(), 4, 4); writer.println("> -----"); writer.flush(); }
Example 13
Source File: ApexCli.java From attic-apex-core with Apache License 2.0 | 5 votes |
@Override void printUsage(String cmd) { super.printUsage(cmd + ((options == null) ? "" : " [options]")); if (options != null) { System.out.println("Options:"); HelpFormatter formatter = new HelpFormatter(); PrintWriter pw = new PrintWriter(System.out); formatter.printOptions(pw, 80, options, 4, 4); pw.flush(); } }
Example 14
Source File: BoaMain.java From compiler with Apache License 2.0 | 5 votes |
protected static final void printHelp (final Options options, final String message) { if (message != null) System.err.println(message); final HelpFormatter help = new HelpFormatter(); final PrintWriter pw = new PrintWriter(System.out); help.printWrapped(pw, HelpFormatter.DEFAULT_WIDTH, "The available options are:"); help.printOptions(pw, HelpFormatter.DEFAULT_WIDTH, options, HelpFormatter.DEFAULT_LEFT_PAD, HelpFormatter.DEFAULT_DESC_PAD); help.printWrapped(pw, HelpFormatter.DEFAULT_WIDTH, "\nPlease report issues at http://www.github.com/boalang/compiler"); pw.flush(); }
Example 15
Source File: SqoopFunction.java From sqoop-on-spark with Apache License 2.0 | 4 votes |
public void printHelp() { HelpFormatter formatter = new HelpFormatter(); formatter.printOptions(getIo().out, formatter.getWidth(), this, 0, 4); }
Example 16
Source File: MainImpl.java From tomee with Apache License 2.0 | 4 votes |
private static void help(final boolean printHeader) { // Here we are using commons-cli to create the list of available commands // We actually use a different Options object to parse the 'openejb' command try { final Options options = new Options(); final ResourceFinder commandFinder = new ResourceFinder("META-INF"); final Map<String, Properties> commands = commandFinder.mapAvailableProperties("org.apache.openejb.cli"); for (final Map.Entry<String, Properties> command : commands.entrySet()) { if (command.getKey().contains(".")) { continue; } final Properties p = command.getValue(); final String description = p.getProperty(descriptionI18n, p.getProperty(descriptionBase)); options.addOption(command.getKey(), false, description); } final HelpFormatter formatter = new HelpFormatter(); final StringWriter sw = new StringWriter(); final PrintWriter pw = new PrintWriter(sw); final String syntax = "openejb <command> [options] [args]"; final String header = "\nAvailable commands:"; final String footer = "\n" + "Try 'openejb <command> --help' for help on a specific command.\n" + "For example 'openejb deploy --help'.\n" + "Important: to display exceptions while running commands, add -e option.\n" + "\n" + "Apache OpenEJB -- EJB Container System and Server.\n" + "For additional information, see http://tomee.apache.org\n" + "Bug Reports to <[email protected]>"; if (!printHeader) { pw.append(header).append("\n\n"); formatter.printOptions(pw, 74, options, 1, 3); } else { formatter.printHelp(pw, 74, syntax, header, options, 1, 3, footer, false); } pw.flush(); // Fix up the commons-cli output to our liking. String text = sw.toString().replaceAll("\n -", "\n "); text = text.replace("\nApache OpenEJB", "\n\nApache OpenEJB"); System.out.print(text); } catch (final IOException e) { e.printStackTrace(); } }