org.apache.commons.cli.Option.setArgName()方法的使用及代码示例

x33g5p2x  于2022-01-25 转载在 其他  
字(6.8k)|赞(0)|评价(0)|浏览(194)

本文整理了Java中org.apache.commons.cli.Option.setArgName()方法的一些代码示例,展示了Option.setArgName()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Option.setArgName()方法的具体详情如下:
包路径:org.apache.commons.cli.Option
类名称:Option
方法名:setArgName

Option.setArgName介绍

[英]Sets the display name for the argument value.
[中]设置参数值的显示名称。

代码示例

代码示例来源:origin: OpenHFT/Chronicle-Queue

public static void addOption(final Options options, final String opt, final String argName, final boolean hasArg,
               final String description, final boolean isRequired) {
  final Option option = new Option(opt, hasArg, description);
  option.setArgName(argName);
  option.setRequired(isRequired);
  options.addOption(option);
}

代码示例来源:origin: commons-cli/commons-cli

@Before
public void setUp() {
  options = new Options();
  Option algorithm = new Option("a" , "algo", true, "the algorithm which it to perform executing");
  algorithm.setArgName("algorithm name");
  options.addOption(algorithm);
  Option key = new Option("k" , "key", true, "the key the setted algorithm uses to process");
  algorithm.setArgName("value");
  options.addOption(key);
  parser = new PosixParser();
}

代码示例来源:origin: commons-cli/commons-cli

@Test
public void testPrintOptionWithEmptyArgNameUsage()
{
  Option option = new Option("f", true, null);
  option.setArgName("");
  option.setRequired(true);
  Options options = new Options();
  options.addOption(option);
  StringWriter out = new StringWriter();
  HelpFormatter formatter = new HelpFormatter();
  formatter.printUsage(new PrintWriter(out), 80, "app", options);
  assertEquals("usage: app -f" + EOL, out.toString());
}

代码示例来源:origin: commons-cli/commons-cli

@Test
public void testHasArgName()
{
  Option option = new Option("f", null);
  option.setArgName(null);
  assertFalse(option.hasArgName());
  option.setArgName("");
  assertFalse(option.hasArgName());
  option.setArgName("file");
  assertTrue(option.hasArgName());
}

代码示例来源:origin: commons-cli/commons-cli

option.setType(type);
option.setValueSeparator(valuesep);
option.setArgName(argName);

代码示例来源:origin: apache/ignite

/**
   * Creates cli options.
   *
   * @return Command line options
   */
  private static Options createOptions() {
    Options options = new Options();

    OptionGroup grp = new OptionGroup();

    grp.setRequired(true);

    Option cfg = new Option(OPTION_CFG, null, true, "path to Spring XML configuration file.");

    cfg.setArgName("file");

    Option n = new Option(null, OPTION_N, true, "nodes count.");

    n.setValueSeparator('=');
    n.setType(Integer.class);

    grp.addOption(cfg);
    grp.addOption(n);

    options.addOptionGroup(grp);

    return options;
  }
}

代码示例来源:origin: apache/accumulo

public static Option endRowOpt() {
 final Option o = new Option(END_ROW_OPT, "end-row", true, "end row (inclusive)");
 o.setArgName("end-row");
 return o;
}

代码示例来源:origin: apache/accumulo

public static Option tableOpt(final String description) {
 final Option tableOpt = new Option(ShellOptions.tableOption, "table", true, description);
 tableOpt.setArgName("table");
 tableOpt.setRequired(false);
 return tableOpt;
}

代码示例来源:origin: apache/metron

@Override
 public Option apply(@Nullable String s) {
  Option o = new Option(s, "tmp_dir", true, "Directory for landing the temporary GeoLite2 data - defaults to /tmp");
  o.setArgName("TMP_DIR");
  o.setRequired(false);
  return o;
 }
}),

代码示例来源:origin: apache/metron

@Nullable
 @Override
 public Option apply(@Nullable String s) {
  Option o = new Option(s, "time_between_polls", true, "The time between polls (in ms)");
  o.setArgName("MS");
  o.setRequired(false);
  return o;
 }
})

代码示例来源:origin: apache/metron

@Nullable
 @Override
 public Option apply(@Nullable String s) {
  Option o = new Option(s, "log4j", true, "The log4j properties file to load");
  o.setArgName("FILE");
  o.setRequired(false);
  return o;
 }
})

代码示例来源:origin: apache/metron

@Nullable
 @Override
 public Option apply(@Nullable String s) {
  Option o = new Option(s, "enrichment_config", true
      , "JSON Document describing the enrichment configuration details." +
      "  This is used to associate an enrichment type with a field type in zookeeper."
  );
  o.setArgName("JSON_FILE");
  o.setRequired(false);
  return o;
 }
})

代码示例来源:origin: apache/metron

@Nullable
@Override
public Option apply(@Nullable String s) {
 Option o = new Option(s, "log4j", true, "The log4j properties file to load");
 o.setArgName("FILE");
 o.setRequired(false);
 return o;
}

代码示例来源:origin: apache/metron

@Nullable
@Override
public Option apply(@Nullable String s) {
 Option o = new Option(s, "lookback", true, "When summarizing, how many monitoring periods should we summarize over?  If 0, then no summary.  Default: 5");
 o.setArgName("LOOKBACK");
 o.setRequired(false);
 return o;
}

代码示例来源:origin: apache/metron

@Nullable
@Override
public Option apply(@Nullable String s) {
 Option o = new Option(s, "eps", true, "The target events per second");
 o.setArgName("EPS");
 o.setRequired(false);
 return o;
}

代码示例来源:origin: apache/metron

@Nullable
@Override
public Option apply(@Nullable String s) {
 Option o = new Option(s, "hbase_table", true, "HBase table to ingest the data into.");
 o.setArgName("TABLE");
 o.setRequired(true);
 return o;
}

代码示例来源:origin: apache/accumulo

@Override
public Options getOptions() {
 final Options opts = new Options();
 tserverOption = new Option("ts", "tabletServer", true, "tablet server to list scans for");
 tserverOption.setArgName("tablet server");
 opts.addOption(tserverOption);
 disablePaginationOpt = new Option("np", "no-pagination", false, "disable pagination of output");
 opts.addOption(disablePaginationOpt);
 return opts;
}

代码示例来源:origin: apache/accumulo

@Override
public Options getOptions() {
 final Options opts = new Options();
 tserverOption = new Option("ts", "tabletServer", true, "tablet server to list bulk imports");
 tserverOption.setArgName("tablet server");
 opts.addOption(tserverOption);
 disablePaginationOpt = new Option("np", "no-pagination", false, "disable pagination of output");
 opts.addOption(disablePaginationOpt);
 return opts;
}

代码示例来源:origin: apache/accumulo

@Override
public Options getOptions() {
 final Options opts = new Options();
 filterOption = new Option("f", "filter", true, "show only compactions that match the regex");
 opts.addOption(filterOption);
 tserverOption = new Option("ts", "tabletServer", true, "tablet server to list compactions for");
 tserverOption.setArgName("tablet server");
 opts.addOption(tserverOption);
 disablePaginationOpt = new Option("np", "no-pagination", false, "disable pagination of output");
 opts.addOption(disablePaginationOpt);
 return opts;
}

代码示例来源:origin: apache/metron

@Nullable
@Override
public Option apply(@Nullable String s) {
 Option o = new Option(s, "percentiles", true
            , "Percentiles to calculate per run. Default: " + Joiner.on(",").join(Arrays.asList(DEFAULT_PERCENTILES))
            );
 o.setArgName("NUM");
 o.setRequired(false);
 return o;
}

相关文章