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

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

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

Option.setOptionalArg介绍

[英]Sets whether this Option can have an optional argument.
[中]设置此选项是否可以有可选参数。

代码示例

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

private void init() {
 try {
  cmdLineOptions.addOption(new Option("help", "Generates a script to execute on 3.x " +
    "cluster.  This requires 3.x binaries on the classpath and hive-site.xml."));
  Option exec = new Option("execute",
    "Executes commands equivalent to generated scrips");
  exec.setOptionalArg(true);
  cmdLineOptions.addOption(exec);
  cmdLineOptions.addOption(new Option("location", true,
    "Location to write scripts to. Default is CWD."));
 }
 catch(Exception ex) {
  LOG.error("init()", ex);
  throw ex;
 }
}
private static IMetaStoreClient getHMS(HiveConf conf) {

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

private void init() {
 try {
  cmdLineOptions.addOption(new Option("help", "Generates a script to execute on 2.x" +
    " cluster.  This requires 2.x binaries on the classpath and hive-site.xml."));
  Option exec = new Option("execute",
    "Executes commands equivalent to generated scrips");
  exec.setOptionalArg(true);
  cmdLineOptions.addOption(exec);
  cmdLineOptions.addOption(new Option("location", true,
    "Location to write scripts to. Default is CWD."));
 }
 catch(Exception ex) {
  LOG.error("init()", ex);
  throw ex;
 }
}
private static HiveMetaHookLoader getHookLoader() {

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

@Test
public void testGetsDefaultIfOptional() throws Exception {
  String[] args = new String[] { "-k", "-a", "Caesar" };
  options.getOption("k").setOptionalArg(true);
  CommandLine line = parser.parse( options, args);
  
  assertEquals( "Caesar", line.getOptionValue("a") );
  assertEquals( "a", line.getOptionValue('k', "a") );
}

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

option.setOptionalArg(optionalArg);
option.setArgs(numberOfArgs);
option.setType(type);

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

option = new Option(null, OPT_TRIM_L, true,
    "Trims leading and trailing spaces from all column values. Column XML names can be optionally specified to set which columns to trim.");
option.setOptionalArg(true);
commandLineOptions.addOption(option);
option = new Option(OPT_JDBC_TO_SFMD, OPT_JDBC_TO_SFMD_L, true,

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

@Override
public Options getOptions() {
 final Options o = new Options();
 secretOption = new Option("s", "secret", true, "specify the instance secret to use");
 secretOption.setOptionalArg(false);
 o.addOption(secretOption);
 statusOption = new Option("t", "status-type", true,
   "filter 'print' on the transaction status type(s) {NEW, IN_PROGRESS,"
     + " FAILED_IN_PROGRESS, FAILED, SUCCESSFUL}");
 statusOption.setArgs(Option.UNLIMITED_VALUES);
 statusOption.setOptionalArg(false);
 o.addOption(statusOption);
 disablePaginationOpt = new Option("np", "no-pagination", false,
   "disables pagination of output");
 o.addOption(disablePaginationOpt);
 return o;
}

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

private Options getOptions() {
  final Options options = new Options();
  options.addOption(SCHEMA_NAME_OPTION);
  options.addOption(DATA_TABLE_OPTION);
  options.addOption(INDEX_TABLE_OPTION);
  options.addOption(PARTIAL_REBUILD_OPTION);
  options.addOption(DIRECT_API_OPTION);
  options.addOption(RUN_FOREGROUND_OPTION);
  options.addOption(OUTPUT_PATH_OPTION);
  options.addOption(SNAPSHOT_OPTION);
  options.addOption(HELP_OPTION);
  AUTO_SPLIT_INDEX_OPTION.setOptionalArg(true);
  options.addOption(AUTO_SPLIT_INDEX_OPTION);
  SPLIT_INDEX_OPTION.setOptionalArg(true);
  options.addOption(SPLIT_INDEX_OPTION);
  return options;
}

代码示例来源:origin: stackoverflow.com

Option lookAndFeelOption = new Option("f", "look-and-feel", true, "This sets the look and feel.");
lookAndFeelOption.setOptionalArg(true);
options.addOption(lookAndFeelOption);

代码示例来源:origin: org.apache.phoenix/phoenix-core

private Options getOptions() {
  final Options options = new Options();
  options.addOption(SCHEMA_NAME_OPTION);
  options.addOption(DATA_TABLE_OPTION);
  options.addOption(INDEX_TABLE_OPTION);
  options.addOption(PARTIAL_REBUILD_OPTION);
  options.addOption(DIRECT_API_OPTION);
  options.addOption(RUN_FOREGROUND_OPTION);
  options.addOption(OUTPUT_PATH_OPTION);
  options.addOption(SNAPSHOT_OPTION);
  options.addOption(HELP_OPTION);
  AUTO_SPLIT_INDEX_OPTION.setOptionalArg(true);
  options.addOption(AUTO_SPLIT_INDEX_OPTION);
  SPLIT_INDEX_OPTION.setOptionalArg(true);
  options.addOption(SPLIT_INDEX_OPTION);
  return options;
}

代码示例来源:origin: com.aliyun.phoenix/ali-phoenix-core

private Options getOptions() {
  final Options options = new Options();
  options.addOption(SCHEMA_NAME_OPTION);
  options.addOption(DATA_TABLE_OPTION);
  options.addOption(INDEX_TABLE_OPTION);
  options.addOption(PARTIAL_REBUILD_OPTION);
  options.addOption(DIRECT_API_OPTION);
  options.addOption(RUN_FOREGROUND_OPTION);
  options.addOption(OUTPUT_PATH_OPTION);
  options.addOption(SNAPSHOT_OPTION);
  options.addOption(HELP_OPTION);
  AUTO_SPLIT_INDEX_OPTION.setOptionalArg(true);
  options.addOption(AUTO_SPLIT_INDEX_OPTION);
  SPLIT_INDEX_OPTION.setOptionalArg(true);
  options.addOption(SPLIT_INDEX_OPTION);
  return options;
}

代码示例来源:origin: org.apache.accumulo/accumulo-shell

@Override
public Options getOptions() {
 final Options o = new Options();
 secretOption = new Option("s", "secret", true, "specify the instance secret to use");
 secretOption.setOptionalArg(false);
 o.addOption(secretOption);
 statusOption = new Option("t", "status-type", true,
   "filter 'print' on the transaction status type(s) {NEW, IN_PROGRESS,"
     + " FAILED_IN_PROGRESS, FAILED, SUCCESSFUL}");
 statusOption.setArgs(Option.UNLIMITED_VALUES);
 statusOption.setOptionalArg(false);
 o.addOption(statusOption);
 disablePaginationOpt = new Option("np", "no-pagination", false,
   "disables pagination of output");
 o.addOption(disablePaginationOpt);
 return o;
}

代码示例来源:origin: org.apache.pig/pig

private Options populateValidOptions() {
  Options validOptions = new Options();
  validOptions.addOption("schema", false, "Loads / Stores the schema of the relation using a hidden JSON file.");
  validOptions.addOption("noschema", false, "Disable attempting to load data schema from the filesystem.");
  validOptions.addOption(TAG_SOURCE_FILE, false, "Appends input source file name to beginning of each tuple.");
  validOptions.addOption(TAG_SOURCE_PATH, false, "Appends input source file path to beginning of each tuple.");
  validOptions.addOption("tagsource", false, "Appends input source file name to beginning of each tuple.");
  Option overwrite = new Option("overwrite", "Overwrites the destination.");
  overwrite.setLongOpt("overwrite");
  overwrite.setOptionalArg(true);
  overwrite.setArgs(1);
  overwrite.setArgName("overwrite");
  validOptions.addOption(overwrite);
  return validOptions;
}

代码示例来源:origin: org.apache.stratos/org.apache.stratos.cli

/**
 * Construct Options.
 *
 * @return Options expected from command-line.
 */
private Options constructOptions() {
  final Options options = new Options();
  Option usernameOption = new Option(CliConstants.USERNAME_OPTION, CliConstants.USERNAME_LONG_OPTION, true,
      "Username");
  usernameOption.setArgName("username");
  options.addOption(usernameOption);
  Option passwordOption = new Option(CliConstants.PASSWORD_OPTION, CliConstants.PASSWORD_LONG_OPTION, true,
      "Password");
  passwordOption.setArgName("password");
  passwordOption.setOptionalArg(true);
  options.addOption(passwordOption);
  options.addOption(CliConstants.HELP_OPTION, CliConstants.HELP_LONG_OPTION, false, "Display this help");
  options.addOption(CliConstants.TRACE_OPTION, false, "Enable trace logging");
  options.addOption(CliConstants.DEBUG_OPTION, false, "Enable debug logging");
  return options;
}

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

private static Options createCommandLine() {
 Options options = new Options();
 options.addOption( HELP_SHORT, HELP_LONG, false, res.helpMessage() );
 options.addOption( VERSION_SHORT, VERSION_LONG, false, res.versionHelpMessage() );
 Option redeploy = new Option( REDEPLOY_SHORT, REDEPLOY_LONG, true, res.redeployHelpMessage() );
 redeploy.setOptionalArg( true );
 options.addOption( redeploy );
 options.addOption( PERSIST_SHORT, PERSIST_LONG, false, res.persistMasterHelpMessage() );
 options.addOption( NOSTART_SHORT, NOSTART_LONG, false, res.nostartHelpMessage() );
 return options;
}

代码示例来源:origin: org.apache.knox/gateway-server

private static Options createCommandLine() {
 Options options = new Options();
 options.addOption( HELP_SHORT, HELP_LONG, false, res.helpMessage() );
 options.addOption( VERSION_SHORT, VERSION_LONG, false, res.versionHelpMessage() );
 Option redeploy = new Option( REDEPLOY_SHORT, REDEPLOY_LONG, true, res.redeployHelpMessage() );
 redeploy.setOptionalArg( true );
 options.addOption( redeploy );
 options.addOption( PERSIST_SHORT, PERSIST_LONG, false, res.persistMasterHelpMessage() );
 options.addOption( NOSTART_SHORT, NOSTART_LONG, false, res.nostartHelpMessage() );
 return options;
}

代码示例来源:origin: digital-preservation/droid

/**
 * 
 * @return a new option for the parameter.
 */
Option newOption() {
  Option option = new Option(shortName, longName, maxArgs != 0, I18N.getResource(resourceKey));
  option.setArgs(maxArgs == -1 ? Option.UNLIMITED_VALUES : maxArgs);
  if (maxArgs != 0) {
    option.setOptionalArg(!argsRequired);
  }
  option.setArgName(argName);
  
  return option;
}

代码示例来源:origin: org.fusesource.hawtjni/hawtjni-generator

public Option op() {
  Option option = new Option( id!=null ? id : " ", description );
  option.setLongOpt(name);
  option.setRequired( required );
  option.setOptionalArg(optional);
  option.setType( type );
  option.setValueSeparator(sperator);
  if( arg !=null && args==-1 ) {
    args=1;
  }
  option.setArgs(args);
  option.setArgName(arg);
  return option;
}

代码示例来源:origin: fusesource/hawtjni

public Option op() {
  Option option = new Option( id!=null ? id : " ", description );
  option.setLongOpt(name);
  option.setRequired( required );
  option.setOptionalArg(optional);
  option.setType( type );
  option.setValueSeparator(sperator);
  if( arg !=null && args==-1 ) {
    args=1;
  }
  option.setArgs(args);
  option.setArgName(arg);
  return option;
}

代码示例来源:origin: NationalSecurityAgency/datawave

/**
 * Creates an Option using OptionBuilder's State and the given parameters.
 *
 * @param opt
 *            short representation of the option
 * @param longOpt
 *            long representation of the option
 * @param desc
 *            descibes the function of the option
 * @return the new Option
 */
public Option create(final String opt, final String longOpt, final String desc) {
  final Option option = new Option(opt, desc);
  option.setLongOpt(longOpt);
  option.setArgs(args);
  option.setRequired(required);
  option.setOptionalArg(optionalArg);
  option.setType(type);
  option.setValueSeparator(valSeparator);
  
  return option;
}

代码示例来源:origin: org.apache.activemq/apollo-util

public Option op() {
  Option option = new Option( id!=null ? id : " ", description );
  option.setLongOpt(name);
  option.setRequired( required );
  option.setOptionalArg(optional);
  option.setType( type );
  option.setValueSeparator(sperator);
  if( arg !=null && args==-1 ) {
    args=1;
  }
  option.setArgs(args);
  option.setArgName(arg);
  return option;
}

相关文章