当前位置: 首页>>代码示例>>Java>>正文


Java HelpFormatter.setSyntaxPrefix方法代码示例

本文整理汇总了Java中org.apache.commons.cli.HelpFormatter.setSyntaxPrefix方法的典型用法代码示例。如果您正苦于以下问题:Java HelpFormatter.setSyntaxPrefix方法的具体用法?Java HelpFormatter.setSyntaxPrefix怎么用?Java HelpFormatter.setSyntaxPrefix使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.commons.cli.HelpFormatter的用法示例。


在下文中一共展示了HelpFormatter.setSyntaxPrefix方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: printHelp

import org.apache.commons.cli.HelpFormatter; //导入方法依赖的package包/类
public void printHelp() {
    HelpFormatter formatter = new HelpFormatter();
    formatter.setSyntaxPrefix("Usage: ");
    formatter.setOptionComparator(null);

    String columns = System.getenv(ENV_COLUMNS);
    if (columns != null) {
        try {
            formatter.setWidth(Integer.parseInt(columns));
        } catch (Exception e) {
            logger.warn(e.toString());
        }
    }

    String header = "Run the " + VersionInfo.PRODUCT + " standalone command-line application.\n\n";
    String leftPadding = StringUtils.repeat(' ', formatter.getLeftPadding());
    //@formatter:off
    String footer = new StringBuilder()
            .append("\nExamples (change directory to " + VersionInfo.PRODUCT + " bin/ first):\n")
            .append(leftPadding + "./" + EXECUTABLE_NAME + " -c ../examples/script/py/hello_world.xml\n")
            .append(leftPadding + "./" + EXECUTABLE_NAME + " -k helloWorldKb=../examples/script/py/hello_world.py\n")
            .append(leftPadding + "./" + EXECUTABLE_NAME + " -k ../examples/script/py/hello_world.py\n")
            .append(leftPadding + "./" + EXECUTABLE_NAME
                    + " -k filtersKb=../examples/script/py/filters.py -k heartbeatKb=../examples/script/js/rules_heartbeat.js\n")
            .append(leftPadding + "./" + EXECUTABLE_NAME
                    + " -k ../examples/standalone/multiple_kb_files/event_processors.py"
                    + ",../examples/standalone/multiple_kb_files/example2.py\n")
            .append("\nPress CTRL+C to exit the " + VersionInfo.PRODUCT + " standalone command-line application.\n")
            .append("\nSee http://sponge.openksavi.org for more details.").toString();
    //@formatter:on
    formatter.printHelp(EXECUTABLE_NAME, header, options, footer, true);
}
 
开发者ID:softelnet,项目名称:sponge,代码行数:33,代码来源:StandaloneEngineBuilder.java

示例2: printHelp

import org.apache.commons.cli.HelpFormatter; //导入方法依赖的package包/类
public void printHelp(String header) {
  HelpFormatter formatter = new HelpFormatter();
  System.out.println(header);
  System.out.println();
  formatter.setSyntaxPrefix("Option pack ");
  for ( OptionPack pack : this ) {
    formatter.printHelp( pack.getClass().getSimpleName(), pack );
  }
}
 
开发者ID:BigBayes,项目名称:BNPMix.java,代码行数:10,代码来源:OptionPacks.java

示例3: printHelpMessage

import org.apache.commons.cli.HelpFormatter; //导入方法依赖的package包/类
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);
}
 
开发者ID:naver,项目名称:hadoop,代码行数:8,代码来源:LogsCLI.java

示例4: print

import org.apache.commons.cli.HelpFormatter; //导入方法依赖的package包/类
public static void print(final Options options, final HelpFormatter formatter) {
    formatter.setSyntaxPrefix("Usage:");
    final StringBuilder protocols = new StringBuilder(StringUtils.LF);
    protocols.append("Supported protocols");
    protocols.append(StringUtils.LF);
    for(Protocol p : ProtocolFactory.get().find()) {
        protocols.append(p.getDescription());
        protocols.append(StringUtils.LF);
        switch(p.getType()) {
            case s3:
            case googlestorage:
            case swift:
                protocols.append("\t").append(String.format("%s://<container>/<key>", p.isBundled() ? p.getIdentifier() : p.getProvider()));
                break;
            default:
                protocols.append("\t").append(String.format("%s://<hostname>/<folder>/<file>", p.isBundled() ? p.getIdentifier() : p.getProvider()));
                break;
        }
        protocols.append(StringUtils.LF);
    }
    final StringBuilder header = new StringBuilder(StringUtils.LF);
    header.append("\t");
    header.append("URLs must be fully qualified. Paths can either denote "
            + "a remote file (ftps://[email protected]/resource) or folder (ftps://[email protected]/directory/) "
            + "with a trailing slash. You can reference files relative to your home directory with /~ (ftps://[email protected]/~/).");
    header.append(protocols.toString());
    final Preferences preferences = PreferencesFactory.get();
    final Local profiles = LocalFactory.get(preferences.getProperty("application.support.path"),
            PreferencesFactory.get().getProperty("profiles.folder.name"));
    header.append(StringUtils.LF);
    header.append(String.format("You can install additional connection profiles in %s",
            profiles.getAbbreviatedPath()));
    header.append(StringUtils.LF);
    final StringBuilder footer = new StringBuilder(StringUtils.LF);
    footer.append(String.format("Cyberduck is libre software licenced under the GPL. For general help about using Cyberduck, please refer to %s and the wiki at %s. For bug reports or feature requests open a ticket at %s.",
            preferences.getProperty("website.cli"), preferences.getProperty("website.help"), MessageFormat.format(preferences.getProperty("website.bug"), preferences.getProperty("application.version"))));
    final License l = LicenseFactory.find();
    footer.append(StringUtils.LF);
    if(l.verify(new DisabledLicenseVerifierCallback())) {
        footer.append(l.toString());
    }
    else {
        footer.append("Not registered. Purchase a donation key to support the development of this software.");
    }
    formatter.printHelp("duck [options...]", header.toString(), options, footer.toString());
}
 
开发者ID:iterate-ch,项目名称:cyberduck,代码行数:47,代码来源:TerminalHelpPrinter.java


注:本文中的org.apache.commons.cli.HelpFormatter.setSyntaxPrefix方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。