org.apache.commons.cli.HelpFormatter#setWidth ( )源码实例Demo

下面列出了org.apache.commons.cli.HelpFormatter#setWidth ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: DDMQ   文件: ServerUtil.java
public static CommandLine parseCmdLine(final String appName, String[] args, Options options,
    CommandLineParser parser) {
    HelpFormatter hf = new HelpFormatter();
    hf.setWidth(110);
    CommandLine commandLine = null;
    try {
        commandLine = parser.parse(options, args);
        if (commandLine.hasOption('h')) {
            hf.printHelp(appName, options, true);
            return null;
        }
    } catch (ParseException e) {
        hf.printHelp(appName, options, true);
    }

    return commandLine;
}
 
源代码2 项目: DDMQ   文件: ServerUtil.java
public static CommandLine parseCmdLine(final String appName, String[] args, Options options,
    CommandLineParser parser) {
    HelpFormatter hf = new HelpFormatter();
    hf.setWidth(110);
    CommandLine commandLine = null;
    try {
        commandLine = parser.parse(options, args);
        if (commandLine.hasOption('h')) {
            hf.printHelp(appName, options, true);
            return null;
        }
    } catch (ParseException e) {
        hf.printHelp(appName, options, true);
    }

    return commandLine;
}
 
源代码3 项目: bboxdb   文件: CLI.java
/**
 * Print help and exit the program
 * @param options
 */
private static void printHelpAndExit() {

	final Options options = OptionsHelper.buildOptions();

	final String allActions = CLIAction.ALL_ACTIONS
			.stream().collect(Collectors.joining(", ", "[", "]"));

	final String allBuilder = TupleBuilderFactory.ALL_BUILDER
			.stream().collect(Collectors.joining(", ", "[", "]"));

	final String header = "BBoxDB command line interace (CLI)\n\n"
			+ "Available actions are: " + allActions + "\n"
			+ "Supported import formats: " + allBuilder + "\n\n";

	final String footer = "\nPlease report issues at https://github.com/jnidzwetzki/bboxdb/issues\n";

	final HelpFormatter formatter = new HelpFormatter();
	formatter.setWidth(120);
	formatter.printHelp("CLI", header, options, footer);

	System.exit(-1);
}
 
源代码4 项目: ofexport2   文件: ActiveOptionProcessor.java
@SuppressWarnings("unchecked")
public void printHelp() throws IOException {

    System.out.println (progName.toUpperCase());
    System.out.println();

    try (
        InputStream in = this.getClass().getResourceAsStream("/version.properties")) {
        Properties p = new Properties();
        p.load(in);
        System.out.println ("Version: " + p.getProperty("version"));
        System.out.println ("Build Date: " + p.getProperty("date"));

    }

    System.out.println();

    HelpFormatter formatter = new HelpFormatter();
    formatter.setWidth(200);
    // Output in the order I specify
    formatter.setOptionComparator((x, y) -> ((ActiveOption<P>) x).getOrder() - ((ActiveOption<P>) y).getOrder());
    formatter.printHelp(progName, options);
}
 
源代码5 项目: jumbune   文件: JumbuneAgent.java
private static void displayOptions(Options options) {
	HelpFormatter formatter = new HelpFormatter();
	formatter.setOptionComparator(null);
	formatter.setWidth(80);
	formatter.printHelp("java -jar <jumbune jar file>.jar", options, true);
	exitVM(0);
}
 
源代码6 项目: flink   文件: CliFrontendParser.java
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();
}
 
源代码7 项目: nifi   文件: AbstractCommand.java
@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();
}
 
源代码8 项目: Flink-CEPplus   文件: CliFrontendParser.java
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();
}
 
源代码9 项目: tez   文件: ATSImportTool.java
static void printHelp(Options options) {
  HelpFormatter formatter = new HelpFormatter();
  formatter.setWidth(240);
  String help = LINE_SEPARATOR
      + "java -cp tez-history-parser-x.y.z-jar-with-dependencies.jar org.apache.tez.history.ATSImportTool"
      + LINE_SEPARATOR
      + "OR"
      + LINE_SEPARATOR
      + "HADOOP_CLASSPATH=$TEZ_HOME/*:$TEZ_HOME/lib/*:$HADOOP_CLASSPATH hadoop jar "
      + "tez-history-parser-x.y.z.jar " + ATSImportTool.class.getName()
      + LINE_SEPARATOR;
  formatter.printHelp(240, help, "Options", options, "", true);
}
 
源代码10 项目: stratosphere   文件: CliFrontend.java
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()));
}
 
源代码11 项目: flink   文件: CliFrontendParser.java
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();
}
 
源代码12 项目: flink   文件: CliFrontendParser.java
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();
}
 
源代码13 项目: flink   文件: CliOptionsParser.java
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();
}
 
源代码14 项目: coming   文件: ComingMain.java
private static void help() {

		HelpFormatter formater = new HelpFormatter();
		formater.setWidth(500);
		formater.printHelp("Main", options);
		logm.info("More options and default values at 'config-coming.properties' file");

	}
 
源代码15 项目: rocketmq-read   文件: ServerUtil.java
public static void printCommandLineHelp(final String appName, final Options options) {
    HelpFormatter hf = new HelpFormatter();
    hf.setWidth(110);
    hf.printHelp(appName, options, true);
}
 
源代码16 项目: helix   文件: ExampleProcess.java
public static void printUsage(Options cliOptions) {
  HelpFormatter helpFormatter = new HelpFormatter();
  helpFormatter.setWidth(1000);
  helpFormatter.printHelp("java " + ExampleProcess.class.getName(), cliOptions);
}
 
源代码17 项目: rocketmq-all-4.1.0-incubating   文件: ServerUtil.java
public static void printCommandLineHelp(final String appName, final Options options) {
    HelpFormatter hf = new HelpFormatter();
    hf.setWidth(110);
    hf.printHelp(appName, options, true);
}
 
源代码18 项目: djl   文件: AbstractBenchmark.java
private void printHelp(String msg, Options options) {
    HelpFormatter formatter = new HelpFormatter();
    formatter.setLeftPadding(1);
    formatter.setWidth(120);
    formatter.printHelp(msg, options);
}
 
源代码19 项目: djl   文件: Main.java
public static void main(String[] args) {
    Options options = Config.getOptions();
    try {
        DefaultParser cmdParser = new DefaultParser();
        CommandLine cmd = cmdParser.parse(options, args, null, false);
        Config config = new Config(cmd);

        String output = config.getOutput();
        String packageName = config.getPackageName();
        String library = config.getLibrary();
        String[] headerFiles = config.getHeaderFiles();
        String mappingFile = config.getMappingFile();

        Path dir = Paths.get(output);
        Files.createDirectories(dir);

        Properties mapping = new Properties();
        if (mappingFile != null) {
            Path file = Paths.get(mappingFile);
            if (Files.notExists(file)) {
                logger.error("mapping file does not exists: {}", mappingFile);
                System.exit(-1); // NOPMD
            }
            try (InputStream in = Files.newInputStream(file)) {
                mapping.load(in);
            }
        }

        JnaParser jnaParser = new JnaParser();
        Map<String, TypeDefine> typedefMap = jnaParser.getTypedefMap();
        Map<String, List<TypeDefine>> structMap = jnaParser.getStructMap();
        JnaGenerator generator =
                new JnaGenerator(library, packageName, typedefMap, structMap.keySet(), mapping);
        generator.init(output);

        for (String headerFile : headerFiles) {
            jnaParser.parse(headerFile);
        }

        generator.writeNativeSize();
        generator.writeStructure(structMap);
        generator.writeLibrary(jnaParser.getFunctions(), jnaParser.getEnumMap());
    } catch (ParseException e) {
        HelpFormatter formatter = new HelpFormatter();
        formatter.setLeftPadding(1);
        formatter.setWidth(120);
        formatter.printHelp(e.getMessage(), options);
        System.exit(-1); // NOPMD
    } catch (Throwable t) {
        logger.error("", t);
        System.exit(-1); // NOPMD
    }
}
 
源代码20 项目: helix   文件: CurrentStateCleanUp.java
public static void printUsage(Options cliOptions) {
  HelpFormatter helpFormatter = new HelpFormatter();
  helpFormatter.setWidth(1000);
  helpFormatter.printHelp("java " + CurrentStateCleanUp.class.getName(), cliOptions);
}