本文整理了Java中org.apache.commons.cli.Option.setArgs()
方法的一些代码示例,展示了Option.setArgs()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Option.setArgs()
方法的具体详情如下:
包路径:org.apache.commons.cli.Option
类名称:Option
方法名:setArgs
[英]Sets the number of argument values this Option can take.
[中]设置此选项可以接受的参数值的数量。
代码示例来源:origin: stackoverflow.com
Options options = new Options();
Option option = new Option("c", "c desc");
// Set option c to take 1 to oo arguments
option.setArgs(Option.UNLIMITED_VALUES);
options.addOption(option);
代码示例来源:origin: alibaba/jstorm
opts.addOption(JOYConstants.SHELL_ARGS, true, "Command line args for the shell script." +
"Multiple args can be separated by empty space.");
opts.getOption(JOYConstants.SHELL_ARGS).setArgs(Option.UNLIMITED_VALUES);
opts.addOption(JOYConstants.SHELL_ENV, true, "Environment for shell script. Specified as env_key=env_val pairs");
opts.addOption(JOYConstants.SHELL_CMD_PRIORITY, true, "Priority for the shell command containers");
代码示例来源:origin: commons-cli/commons-cli
@Test
public void test31148() throws ParseException
{
Option multiArgOption = new Option("o","option with multiple args");
multiArgOption.setArgs(1);
Options options = new Options();
options.addOption(multiArgOption);
Parser parser = new PosixParser();
String[] args = new String[]{};
Properties props = new Properties();
props.setProperty("o","ovalue");
CommandLine cl = parser.parse(options,args,props);
assertTrue(cl.hasOption('o'));
assertEquals("ovalue",cl.getOptionValue('o'));
}
代码示例来源:origin: commons-cli/commons-cli
@Test
public void testHasArgs()
{
Option option = new Option("f", null);
option.setArgs(0);
assertFalse(option.hasArgs());
option.setArgs(1);
assertFalse(option.hasArgs());
option.setArgs(10);
assertTrue(option.hasArgs());
option.setArgs(Option.UNLIMITED_VALUES);
assertTrue(option.hasArgs());
option.setArgs(Option.UNINITIALIZED);
assertFalse(option.hasArgs());
}
代码示例来源:origin: commons-cli/commons-cli
option.setRequired(required);
option.setOptionalArg(optionalArg);
option.setArgs(numberOfArgs);
option.setType(type);
option.setValueSeparator(valuesep);
代码示例来源:origin: commons-cli/commons-cli
option = new Option(OPT_JDBC_TO_SFMD, OPT_JDBC_TO_SFMD_L, true,
"Converts the JDBC file in the first argument to an SMFD file specified in the second argument.");
option.setArgs(2);
commandLineOptions.addOption(option);
代码示例来源:origin: stackoverflow.com
Options options = new Options();
Option option = new Option("c", "c desc");
// Set option c to take maximum of 10 arguments
option.setArgs(10);
options.addOption(option);
代码示例来源:origin: commons-cli/commons-cli
@Test
public void testGetValue()
{
Option option = new Option("f", null);
option.setArgs(Option.UNLIMITED_VALUES);
assertEquals("default", option.getValue("default"));
assertEquals(null, option.getValue(0));
option.addValueForProcessing("foo");
assertEquals("foo", option.getValue());
assertEquals("foo", option.getValue(0));
assertEquals("foo", option.getValue("default"));
}
代码示例来源: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/tika
private Option buildOption(Node optionNode) {
NamedNodeMap map = optionNode.getAttributes();
String opt = getString(map, "opt", "");
String description = getString(map, "description", "");
String longOpt = getString(map, "longOpt", "");
boolean isRequired = getBoolean(map, "required", false);
boolean hasArg = getBoolean(map, "hasArg", false);
if(opt.trim().length() == 0 || description.trim().length() == 0) {
throw new IllegalArgumentException(
"Must specify at least option and description");
}
Option option = new Option(opt, description);
if (longOpt.trim().length() > 0) {
option.setLongOpt(longOpt);
}
if (isRequired) {
option.setRequired(true);
}
if (hasArg) {
option.setArgs(1);
}
return option;
}
代码示例来源:origin: GoogleCloudPlatform/java-docs-samples
infoTypesOption.setArgs(Option.UNLIMITED_VALUES);
commandLineOptions.addOption(infoTypesOption);
代码示例来源:origin: apache/accumulo
engine.setArgs(1);
engine.setRequired(false);
o.addOption(engine);
script.setArgs(1);
script.setRequired(false);
inputGroup.addOption(script);
file.setArgs(1);
file.setRequired(false);
object.setArgs(1);
object.setArgName("objectName:methodName");
object.setRequired(false);
function.setArgs(1);
function.setRequired(false);
invokeGroup.addOption(function);
args.setArgs(Option.UNLIMITED_VALUES);
args.setRequired(false);
o.addOption(args);
out.setArgs(1);
out.setRequired(false);
o.addOption(out);
代码示例来源:origin: GoogleCloudPlatform/java-docs-samples
infoTypesOption.setArgs(Option.UNLIMITED_VALUES);
commandLineOptions.addOption(infoTypesOption);
代码示例来源:origin: GoogleCloudPlatform/java-docs-samples
infoTypesOption.setArgs(Option.UNLIMITED_VALUES);
commandLineOptions.addOption(infoTypesOption);
代码示例来源:origin: GoogleCloudPlatform/java-docs-samples
quasiIdColumnNamesOption.setArgs(Option.UNLIMITED_VALUES);
commandLineOptions.addOption(quasiIdColumnNamesOption);
infoTypesOption.setArgs(Option.UNLIMITED_VALUES);
commandLineOptions.addOption(infoTypesOption);
代码示例来源:origin: apache/accumulo
"create locality groups at table creation");
createTableOptLocalityProps.setArgName("group=col_fam[,col_fam]");
createTableOptLocalityProps.setArgs(Option.UNLIMITED_VALUES);
+ " scopes are activated.");
createTableOptIteratorProps.setArgName("profile[:[all]|[scan[,]][minc[,]][majc]]");
createTableOptIteratorProps.setArgs(Option.UNLIMITED_VALUES);
代码示例来源:origin: GoogleCloudPlatform/java-docs-samples
infoTypesOption.setArgs(Option.UNLIMITED_VALUES);
commandLineOptions.addOption(infoTypesOption);
代码示例来源:origin: GoogleCloudPlatform/java-docs-samples
infoTypesOption.setArgs(Option.UNLIMITED_VALUES);
commandLineOptions.addOption(infoTypesOption);
customDictionariesOption.setArgs(Option.UNLIMITED_VALUES);
commandLineOptions.addOption(customDictionariesOption);
customRegexesOption.setArgs(Option.UNLIMITED_VALUES);
commandLineOptions.addOption(customRegexesOption);
代码示例来源:origin: kieker-monitoring/kieker
@Override
protected void addAdditionalOptions(final Options options) {
final Option option = new Option(FLAG_TIMESTAMPS_PARAMETER, "timestamps", true,
"List of timestamps (UTC timezone) to convert");
option.setArgName("timestamp1 ... timestampN");
option.setRequired(false);
option.setArgs(Option.UNLIMITED_VALUES);
options.addOption(option);
}
代码示例来源:origin: org.apache.helix/helix-core
/** Constructs option group containing options required by all drivable jobs */
private static OptionGroup constructStartOptionGroup() {
@SuppressWarnings("static-access")
Option workflowFileOption =
OptionBuilder.withLongOpt(WORKFLOW_FILE_OPTION)
.withDescription("Local file describing workflow").create();
workflowFileOption.setArgs(1);
workflowFileOption.setArgName("workflowFile");
OptionGroup group = new OptionGroup();
group.addOption(workflowFileOption);
return group;
}
内容来源于网络,如有侵权,请联系作者删除!