Java Code Examples for org.apache.commons.cli.HelpFormatter#setSyntaxPrefix()

The following examples show how to use org.apache.commons.cli.HelpFormatter#setSyntaxPrefix() . 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: Client.java    From stratosphere with Apache License 2.0 6 votes vote down vote up
private void printUsage() {
	System.out.println("Usage:");
	HelpFormatter formatter = new HelpFormatter();
	formatter.setWidth(200);
	formatter.setLeftPadding(5);
	formatter.setSyntaxPrefix("   Required");
	Options req = new Options();
	req.addOption(CONTAINER);
	formatter.printHelp(" ", req);
	
	formatter.setSyntaxPrefix("   Optional");
	Options opt = new Options();
	opt.addOption(VERBOSE);
//	opt.addOption(GEN_CONF);
//	opt.addOption(STRATOSPHERE_CONF);
//	opt.addOption(STRATOSPHERE_JAR);
	opt.addOption(JM_MEMORY);
	opt.addOption(TM_MEMORY);
	opt.addOption(TM_CORES);
	opt.addOption(QUERY);
	opt.addOption(QUEUE);
	formatter.printHelp(" ", opt);
}
 
Example 2
Source File: CliFrontendParser.java    From flink with Apache License 2.0 6 votes vote down vote up
/**
 * Prints custom cli options.
 * @param formatter The formatter to use for printing
 * @param runOptions True if the run options should be printed, False to print only general options
 */
private static void printCustomCliOptions(
		Collection<CustomCommandLine<?>> customCommandLines,
		HelpFormatter formatter,
		boolean runOptions) {
	// prints options from all available command-line classes
	for (CustomCommandLine cli: customCommandLines) {
		formatter.setSyntaxPrefix("  Options for " + cli.getId() + " mode:");
		Options customOpts = new Options();
		cli.addGeneralOptions(customOpts);
		if (runOptions) {
			cli.addRunOptions(customOpts);
		}
		formatter.printHelp(" ", customOpts);
		System.out.println();
	}
}
 
Example 3
Source File: CliFrontendParser.java    From flink with Apache License 2.0 6 votes vote down vote up
/**
 * Prints custom cli options.
 * @param formatter The formatter to use for printing
 * @param runOptions True if the run options should be printed, False to print only general options
 */
private static void printCustomCliOptions(
		Collection<CustomCommandLine> customCommandLines,
		HelpFormatter formatter,
		boolean runOptions) {
	// prints options from all available command-line classes
	for (CustomCommandLine cli: customCommandLines) {
		formatter.setSyntaxPrefix("  Options for " + cli.getId() + " mode:");
		Options customOpts = new Options();
		cli.addGeneralOptions(customOpts);
		if (runOptions) {
			cli.addRunOptions(customOpts);
		}
		formatter.printHelp(" ", customOpts);
		System.out.println();
	}
}
 
Example 4
Source File: CliOptionsParser.java    From flink with Apache License 2.0 5 votes vote down vote up
public static void printHelpEmbeddedModeClient() {
	HelpFormatter formatter = new HelpFormatter();
	formatter.setLeftPadding(5);
	formatter.setWidth(80);

	System.out.println("\nMode \"embedded\" submits Flink jobs from the local machine.");
	System.out.println("\n  Syntax: embedded [OPTIONS]");
	formatter.setSyntaxPrefix("  \"embedded\" mode options:");
	formatter.printHelp(" ", EMBEDDED_MODE_CLIENT_OPTIONS);

	System.out.println();
}
 
Example 5
Source File: CliFrontendParser.java    From flink with Apache License 2.0 5 votes vote down vote up
public static void printHelpForSavepoint(Collection<CustomCommandLine<?>> customCommandLines) {
	HelpFormatter formatter = new HelpFormatter();
	formatter.setLeftPadding(5);
	formatter.setWidth(80);

	System.out.println("\nAction \"savepoint\" triggers savepoints for a running job or disposes existing ones.");
	System.out.println("\n  Syntax: savepoint [OPTIONS] <Job ID> [<target directory>]");
	formatter.setSyntaxPrefix("  \"savepoint\" action options:");
	formatter.printHelp(" ", getSavepointOptionsWithoutDeprecatedOptions(new Options()));

	printCustomCliOptions(customCommandLines, formatter, false);

	System.out.println();
}
 
Example 6
Source File: CommandLineArguments.java    From zserio with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
/**
 * Prints help.
 */
public void printHelp()
{
    final HelpFormatter hf = new HelpFormatter();

    hf.setSyntaxPrefix("Usage: ");
    hf.setLeftPadding(2);
    hf.setOptionComparator(null);
    hf.printHelp("java -jar zserio.jar <options> zserioInputFile\n", "Options:", options, null, false);
    ZserioToolPrinter.printMessage("");
}
 
Example 7
Source File: CliFrontendParser.java    From flink with Apache License 2.0 5 votes vote down vote up
public static void printHelpForStop(Collection<CustomCommandLine<?>> customCommandLines) {
	HelpFormatter formatter = new HelpFormatter();
	formatter.setLeftPadding(5);
	formatter.setWidth(80);

	System.out.println("\nAction \"stop\" stops a running program with a savepoint (streaming jobs only).");
	System.out.println("\n  Syntax: stop [OPTIONS] <Job ID>");
	formatter.setSyntaxPrefix("  \"stop\" action options:");
	formatter.printHelp(" ", getStopOptionsWithoutDeprecatedOptions(new Options()));

	printCustomCliOptions(customCommandLines, formatter, false);

	System.out.println();
}
 
Example 8
Source File: CliFrontendParser.java    From flink with Apache License 2.0 5 votes vote down vote up
public static void printHelpForInfo() {
	HelpFormatter formatter = new HelpFormatter();
	formatter.setLeftPadding(5);
	formatter.setWidth(80);

	System.out.println("\nAction \"info\" shows the optimized execution plan of the program (JSON).");
	System.out.println("\n  Syntax: info [OPTIONS] <jar-file> <arguments>");
	formatter.setSyntaxPrefix("  \"info\" action options:");
	formatter.printHelp(" ", getInfoOptionsWithoutDeprecatedOptions(new Options()));

	System.out.println();
}
 
Example 9
Source File: CliFrontend.java    From stratosphere with Apache License 2.0 5 votes vote down vote up
private void printHelpForList() {
	HelpFormatter formatter = new HelpFormatter();
	formatter.setLeftPadding(5);
	formatter.setWidth(80);
	
	System.out.println("\nAction \"list\" lists running and finished programs.");
	formatter.setSyntaxPrefix("  \"list\" action arguments:");
	formatter.printHelp(" ", getListOptions(new Options()));
}
 
Example 10
Source File: CliFrontendParser.java    From flink with Apache License 2.0 5 votes vote down vote up
public static void printHelpForSavepoint(Collection<CustomCommandLine> customCommandLines) {
	HelpFormatter formatter = new HelpFormatter();
	formatter.setLeftPadding(5);
	formatter.setWidth(80);

	System.out.println("\nAction \"savepoint\" triggers savepoints for a running job or disposes existing ones.");
	System.out.println("\n  Syntax: savepoint [OPTIONS] <Job ID> [<target directory>]");
	formatter.setSyntaxPrefix("  \"savepoint\" action options:");
	formatter.printHelp(" ", getSavepointOptionsWithoutDeprecatedOptions(new Options()));

	printCustomCliOptions(customCommandLines, formatter, false);

	System.out.println();
}
 
Example 11
Source File: CliFrontendParser.java    From flink with Apache License 2.0 5 votes vote down vote up
public static void printHelpForList(Collection<CustomCommandLine> customCommandLines) {
	HelpFormatter formatter = new HelpFormatter();
	formatter.setLeftPadding(5);
	formatter.setWidth(80);

	System.out.println("\nAction \"list\" lists running and scheduled programs.");
	System.out.println("\n  Syntax: list [OPTIONS]");
	formatter.setSyntaxPrefix("  \"list\" action options:");
	formatter.printHelp(" ", getListOptionsWithoutDeprecatedOptions(new Options()));

	printCustomCliOptions(customCommandLines, formatter, false);

	System.out.println();
}
 
Example 12
Source File: CliOptionsParser.java    From Flink-CEPplus with Apache License 2.0 5 votes vote down vote up
public static void printHelpEmbeddedModeClient() {
	HelpFormatter formatter = new HelpFormatter();
	formatter.setLeftPadding(5);
	formatter.setWidth(80);

	System.out.println("\nMode \"embedded\" submits Flink jobs from the local machine.");
	System.out.println("\n  Syntax: embedded [OPTIONS]");
	formatter.setSyntaxPrefix("  \"embedded\" mode options:");
	formatter.printHelp(" ", EMBEDDED_MODE_CLIENT_OPTIONS);

	System.out.println();
}
 
Example 13
Source File: CliFrontend.java    From stratosphere with Apache License 2.0 5 votes vote down vote up
private void printHelpForInfo() {
	HelpFormatter formatter = new HelpFormatter();
	formatter.setLeftPadding(5);
	formatter.setWidth(80);
	
	System.out.println("\nAction \"info\" displays information about a program.");
	formatter.setSyntaxPrefix("  \"info\" action arguments:");
	formatter.printHelp(" ", getInfoOptionsWithoutDeprecatedOptions(new Options()));
}
 
Example 14
Source File: CliFrontend.java    From stratosphere with Apache License 2.0 5 votes vote down vote up
private void printHelpForRun() {
	HelpFormatter formatter = new HelpFormatter();
	formatter.setLeftPadding(5);
	formatter.setWidth(80);
	
	System.out.println("\nAction \"run\" compiles and runs a program.");
	System.out.println("\n  Syntax: run [OPTIONS] <jar-file> <arguments>");
	formatter.setSyntaxPrefix("  \"run\" action arguments:");
	formatter.printHelp(" ", getRunOptionsWithoutDeprecatedOptions(new Options()));
}
 
Example 15
Source File: LogsCLI.java    From big-c with Apache License 2.0 5 votes vote down vote up
private void printHelpMessage(Options options) {
  System.out.println("Retrieve logs for completed YARN applications.");
  HelpFormatter formatter = new HelpFormatter();
  formatter.printHelp("yarn logs -applicationId <application ID> [OPTIONS]", new Options());
  formatter.setSyntaxPrefix("");
  formatter.printHelp("general options are:", options);
}
 
Example 16
Source File: CliFrontendParser.java    From Flink-CEPplus with Apache License 2.0 5 votes vote down vote up
public static void printHelpForStop(Collection<CustomCommandLine<?>> customCommandLines) {
	HelpFormatter formatter = new HelpFormatter();
	formatter.setLeftPadding(5);
	formatter.setWidth(80);

	System.out.println("\nAction \"stop\" stops a running program (streaming jobs only).");
	System.out.println("\n  Syntax: stop [OPTIONS] <Job ID>");
	formatter.setSyntaxPrefix("  \"stop\" action options:");
	formatter.printHelp(" ", getStopOptionsWithoutDeprecatedOptions(new Options()));

	printCustomCliOptions(customCommandLines, formatter, false);

	System.out.println();
}
 
Example 17
Source File: CliFrontendParser.java    From Flink-CEPplus with Apache License 2.0 5 votes vote down vote up
public static void printHelpForList(Collection<CustomCommandLine<?>> customCommandLines) {
	HelpFormatter formatter = new HelpFormatter();
	formatter.setLeftPadding(5);
	formatter.setWidth(80);

	System.out.println("\nAction \"list\" lists running and scheduled programs.");
	System.out.println("\n  Syntax: list [OPTIONS]");
	formatter.setSyntaxPrefix("  \"list\" action options:");
	formatter.printHelp(" ", getListOptionsWithoutDeprecatedOptions(new Options()));

	printCustomCliOptions(customCommandLines, formatter, false);

	System.out.println();
}
 
Example 18
Source File: LogsCLI.java    From hadoop with Apache License 2.0 5 votes vote down vote up
private void printHelpMessage(Options options) {
  System.out.println("Retrieve logs for completed YARN applications.");
  HelpFormatter formatter = new HelpFormatter();
  formatter.printHelp("yarn logs -applicationId <application ID> [OPTIONS]", new Options());
  formatter.setSyntaxPrefix("");
  formatter.printHelp("general options are:", options);
}
 
Example 19
Source File: CliFrontendParser.java    From Flink-CEPplus with Apache License 2.0 5 votes vote down vote up
public static void printHelpForRun(Collection<CustomCommandLine<?>> customCommandLines) {
	HelpFormatter formatter = new HelpFormatter();
	formatter.setLeftPadding(5);
	formatter.setWidth(80);

	System.out.println("\nAction \"run\" compiles and runs a program.");
	System.out.println("\n  Syntax: run [OPTIONS] <jar-file> <arguments>");
	formatter.setSyntaxPrefix("  \"run\" action options:");
	formatter.printHelp(" ", getRunOptionsWithoutDeprecatedOptions(new Options()));

	printCustomCliOptions(customCommandLines, formatter, true);

	System.out.println();
}
 
Example 20
Source File: CliFrontend.java    From stratosphere with Apache License 2.0 5 votes vote down vote up
private void printHelpForCancel() {
	HelpFormatter formatter = new HelpFormatter();
	formatter.setLeftPadding(5);
	formatter.setWidth(80);
	
	System.out.println("\nAction \"cancel\" cancels a running program.");
	formatter.setSyntaxPrefix("  \"cancel\" action arguments:");
	formatter.printHelp(" ", getCancelOptions(new Options()));
}