Java 类org.apache.commons.cli.OptionBuilder 实例源码
项目:hadoop-oss
文件:TestGenericOptionsParser.java
/**
* Test that options passed to the constructor are used.
*/
@SuppressWarnings("static-access")
public void testCreateWithOptions() throws Exception {
// Create new option newOpt
Option opt = OptionBuilder.withArgName("int")
.hasArg()
.withDescription("A new option")
.create("newOpt");
Options opts = new Options();
opts.addOption(opt);
// Check newOpt is actually used to parse the args
String[] args = new String[2];
args[0] = "--newOpt";
args[1] = "7";
GenericOptionsParser g = new GenericOptionsParser(opts, args);
assertEquals("New option was ignored",
"7", g.getCommandLine().getOptionValues("newOpt")[0]);
}
项目:aceql-http
文件:WebServer.java
/**
* Create the CLI Options
*
* @return the CLI Options
* @throws IllegalArgumentException
*/
private static Options createOptions() throws IllegalArgumentException {
Options options = new Options();
// add an option
options.addOption("help", false, "print this message");
options.addOption("start", false, "start the SQL Web server");
options.addOption("stop", false, "stop the SQL Web server");
options.addOption("version", false, "print version");
String propertiesOptionMesssage = getPropertiesOptionMessage();
@SuppressWarnings("static-access")
Option propertiesOption = OptionBuilder.withArgName("file").hasArg().withDescription(propertiesOptionMesssage)
.create("properties");
@SuppressWarnings("static-access")
Option hostOption = OptionBuilder.withArgName("hostname").hasArg().withDescription("hostname of the Web server")
.create("host");
@SuppressWarnings("static-access")
Option portOption = OptionBuilder.withArgName("port number").hasArg()
.withDescription("port number of the Web server. Defaults to " + WebServerApi.DEFAULT_PORT)
.create("port");
options.addOption(propertiesOption);
options.addOption(hostOption);
options.addOption(portOption);
return options;
}
项目:aliyun-maxcompute-data-collectors
文件:SQLServerManager.java
/**
* Create related options for SQL Server extra parameters.
*
* @return
*/
@SuppressWarnings("static-access")
private RelatedOptions getExtraOptions() {
// Connection args (common)
RelatedOptions extraOptions =
new RelatedOptions("SQL Server extra options:");
extraOptions.addOption(OptionBuilder.withArgName("string").hasArg()
.withDescription("Optional schema name")
.withLongOpt(SCHEMA).create());
extraOptions.addOption(OptionBuilder.withArgName("string").hasArg()
.withDescription("Optional table hints to use")
.withLongOpt(TABLE_HINTS).create());
extraOptions.addOption(OptionBuilder
.withDescription("Allow identity inserts")
.withLongOpt(IDENTITY_INSERT).create());
return extraOptions;
}
项目:aliyun-maxcompute-data-collectors
文件:DirectPostgresqlManager.java
/** {@inheritDoc}. */
@Override
@SuppressWarnings("static-access")
protected RelatedOptions getExtraOptions() {
RelatedOptions extraOptions = super.getExtraOptions();
extraOptions.addOption(OptionBuilder.withArgName("string").hasArg()
.withDescription("String to encode TRUE value")
.withLongOpt(BOOLEAN_TRUE_STRING).create());
extraOptions.addOption(OptionBuilder.withArgName("string").hasArg()
.withDescription("String to encode FALSE value")
.withLongOpt(BOOLEAN_FALSE_STRING).create());
return extraOptions;
}
项目:aliyun-maxcompute-data-collectors
文件:BaseSqoopTool.java
@SuppressWarnings("static-access")
protected void addValidationOpts(RelatedOptions validationOptions) {
validationOptions.addOption(OptionBuilder
.withDescription("Validate the copy using the configured validator")
.withLongOpt(VALIDATE_ARG)
.create());
validationOptions.addOption(OptionBuilder
.withArgName(VALIDATOR_CLASS_ARG).hasArg()
.withDescription("Fully qualified class name for the Validator")
.withLongOpt(VALIDATOR_CLASS_ARG)
.create());
validationOptions.addOption(OptionBuilder
.withArgName(VALIDATION_THRESHOLD_CLASS_ARG).hasArg()
.withDescription("Fully qualified class name for ValidationThreshold")
.withLongOpt(VALIDATION_THRESHOLD_CLASS_ARG)
.create());
validationOptions.addOption(OptionBuilder
.withArgName(VALIDATION_FAILURE_HANDLER_CLASS_ARG).hasArg()
.withDescription("Fully qualified class name for "
+ "ValidationFailureHandler")
.withLongOpt(VALIDATION_FAILURE_HANDLER_CLASS_ARG)
.create());
}
项目:aliyun-maxcompute-data-collectors
文件:MainframeImportTool.java
@Override
public void configureOptions(ToolOptions toolOptions) {
toolOptions.addUniqueOptions(getCommonOptions());
toolOptions.addUniqueOptions(getImportOptions());
toolOptions.addUniqueOptions(getOutputFormatOptions());
toolOptions.addUniqueOptions(getInputFormatOptions());
toolOptions.addUniqueOptions(getHiveOptions(true));
toolOptions.addUniqueOptions(getHBaseOptions());
toolOptions.addUniqueOptions(getHCatalogOptions());
toolOptions.addUniqueOptions(getHCatImportOnlyOptions());
toolOptions.addUniqueOptions(getAccumuloOptions());
// get common codegen opts.
RelatedOptions codeGenOpts = getCodeGenOpts(false);
// add import-specific codegen opts:
codeGenOpts.addOption(OptionBuilder.withArgName("file")
.hasArg()
.withDescription("Disable code generation; use specified jar")
.withLongOpt(JAR_FILE_NAME_ARG)
.create());
toolOptions.addUniqueOptions(codeGenOpts);
}
项目:aliyun-maxcompute-data-collectors
文件:CodeGenTool.java
@Override
/** Configure the command-line arguments we expect to receive */
public void configureOptions(ToolOptions toolOptions) {
toolOptions.addUniqueOptions(getCommonOptions());
RelatedOptions codeGenOpts = getCodeGenOpts(false);
codeGenOpts.addOption(OptionBuilder.withArgName("table-name")
.hasArg()
.withDescription("Table to generate code for")
.withLongOpt(TABLE_ARG)
.create());
codeGenOpts.addOption(OptionBuilder.withArgName("statement")
.hasArg()
.withDescription("SQL 'statement' to generate code for")
.withLongOpt(SQL_QUERY_ARG)
.create(SQL_QUERY_SHORT_ARG));
toolOptions.addUniqueOptions(codeGenOpts);
toolOptions.addUniqueOptions(getOutputFormatOptions());
toolOptions.addUniqueOptions(getInputFormatOptions());
toolOptions.addUniqueOptions(getHiveOptions(true));
toolOptions.addUniqueOptions(getHCatalogOptions());
}
项目:aliyun-maxcompute-data-collectors
文件:ImportTool.java
/**
* Return options for incremental import.
*/
protected RelatedOptions getIncrementalOptions() {
RelatedOptions incrementalOpts =
new RelatedOptions("Incremental import arguments");
incrementalOpts.addOption(OptionBuilder.withArgName("import-type")
.hasArg()
.withDescription(
"Define an incremental import of type 'append' or 'lastmodified'")
.withLongOpt(INCREMENT_TYPE_ARG)
.create());
incrementalOpts.addOption(OptionBuilder.withArgName("column")
.hasArg()
.withDescription("Source column to check for incremental change")
.withLongOpt(INCREMENT_COL_ARG)
.create());
incrementalOpts.addOption(OptionBuilder.withArgName("value")
.hasArg()
.withDescription("Last imported value in the incremental check column")
.withLongOpt(INCREMENT_LAST_VAL_ARG)
.create());
return incrementalOpts;
}
项目:aliyun-maxcompute-data-collectors
文件:CreateHiveTableTool.java
@Override
/** Configure the command-line arguments we expect to receive */
public void configureOptions(ToolOptions toolOptions) {
toolOptions.addUniqueOptions(getCommonOptions());
RelatedOptions hiveOpts = getHiveOptions(false);
hiveOpts.addOption(OptionBuilder.withArgName("table-name")
.hasArg()
.withDescription("The db table to read the definition from")
.withLongOpt(TABLE_ARG)
.create());
toolOptions.addUniqueOptions(hiveOpts);
toolOptions.addUniqueOptions(getOutputFormatOptions());
}
项目:hadoop
文件:OfflineEditsViewer.java
/**
* Build command-line options and descriptions
*
* @return command line options
*/
public static Options buildOptions() {
Options options = new Options();
// Build in/output file arguments, which are required, but there is no
// addOption method that can specify this
OptionBuilder.isRequired();
OptionBuilder.hasArgs();
OptionBuilder.withLongOpt("outputFilename");
options.addOption(OptionBuilder.create("o"));
OptionBuilder.isRequired();
OptionBuilder.hasArgs();
OptionBuilder.withLongOpt("inputFilename");
options.addOption(OptionBuilder.create("i"));
options.addOption("p", "processor", true, "");
options.addOption("v", "verbose", false, "");
options.addOption("f", "fix-txids", false, "");
options.addOption("r", "recover", false, "");
options.addOption("h", "help", false, "");
return options;
}
项目:hadoop
文件:OfflineImageViewer.java
/**
* Build command-line options and descriptions
*/
public static Options buildOptions() {
Options options = new Options();
// Build in/output file arguments, which are required, but there is no
// addOption method that can specify this
OptionBuilder.isRequired();
OptionBuilder.hasArgs();
OptionBuilder.withLongOpt("outputFile");
options.addOption(OptionBuilder.create("o"));
OptionBuilder.isRequired();
OptionBuilder.hasArgs();
OptionBuilder.withLongOpt("inputFile");
options.addOption(OptionBuilder.create("i"));
options.addOption("p", "processor", true, "");
options.addOption("h", "help", false, "");
options.addOption("skipBlocks", false, "");
options.addOption("printToScreen", false, "");
options.addOption("delimiter", true, "");
return options;
}
项目:hadoop
文件:OfflineImageViewerPB.java
/**
* Build command-line options and descriptions
*/
private static Options buildOptions() {
Options options = new Options();
// Build in/output file arguments, which are required, but there is no
// addOption method that can specify this
OptionBuilder.isRequired();
OptionBuilder.hasArgs();
OptionBuilder.withLongOpt("inputFile");
options.addOption(OptionBuilder.create("i"));
options.addOption("o", "outputFile", true, "");
options.addOption("p", "processor", true, "");
options.addOption("h", "help", false, "");
options.addOption("maxSize", true, "");
options.addOption("step", true, "");
options.addOption("addr", true, "");
options.addOption("delimiter", true, "");
options.addOption("t", "temp", true, "");
return options;
}
项目:hadoop
文件:TestGenericOptionsParser.java
/**
* Test that options passed to the constructor are used.
*/
@SuppressWarnings("static-access")
public void testCreateWithOptions() throws Exception {
// Create new option newOpt
Option opt = OptionBuilder.withArgName("int")
.hasArg()
.withDescription("A new option")
.create("newOpt");
Options opts = new Options();
opts.addOption(opt);
// Check newOpt is actually used to parse the args
String[] args = new String[2];
args[0] = "--newOpt";
args[1] = "7";
GenericOptionsParser g = new GenericOptionsParser(opts, args);
assertEquals("New option was ignored",
"7", g.getCommandLine().getOptionValues("newOpt")[0]);
}
项目:aliyun-oss-hadoop-fs
文件:OfflineEditsViewer.java
/**
* Build command-line options and descriptions
*
* @return command line options
*/
public static Options buildOptions() {
Options options = new Options();
// Build in/output file arguments, which are required, but there is no
// addOption method that can specify this
OptionBuilder.isRequired();
OptionBuilder.hasArgs();
OptionBuilder.withLongOpt("outputFilename");
options.addOption(OptionBuilder.create("o"));
OptionBuilder.isRequired();
OptionBuilder.hasArgs();
OptionBuilder.withLongOpt("inputFilename");
options.addOption(OptionBuilder.create("i"));
options.addOption("p", "processor", true, "");
options.addOption("v", "verbose", false, "");
options.addOption("f", "fix-txids", false, "");
options.addOption("r", "recover", false, "");
options.addOption("h", "help", false, "");
return options;
}
项目:aliyun-oss-hadoop-fs
文件:OfflineImageViewer.java
/**
* Build command-line options and descriptions
*/
public static Options buildOptions() {
Options options = new Options();
// Build in/output file arguments, which are required, but there is no
// addOption method that can specify this
OptionBuilder.isRequired();
OptionBuilder.hasArgs();
OptionBuilder.withLongOpt("outputFile");
options.addOption(OptionBuilder.create("o"));
OptionBuilder.isRequired();
OptionBuilder.hasArgs();
OptionBuilder.withLongOpt("inputFile");
options.addOption(OptionBuilder.create("i"));
options.addOption("p", "processor", true, "");
options.addOption("h", "help", false, "");
options.addOption("skipBlocks", false, "");
options.addOption("printToScreen", false, "");
options.addOption("delimiter", true, "");
return options;
}
项目:aliyun-oss-hadoop-fs
文件:OfflineImageViewerPB.java
/**
* Build command-line options and descriptions
*/
private static Options buildOptions() {
Options options = new Options();
// Build in/output file arguments, which are required, but there is no
// addOption method that can specify this
OptionBuilder.isRequired();
OptionBuilder.hasArgs();
OptionBuilder.withLongOpt("inputFile");
options.addOption(OptionBuilder.create("i"));
options.addOption("o", "outputFile", true, "");
options.addOption("p", "processor", true, "");
options.addOption("h", "help", false, "");
options.addOption("maxSize", true, "");
options.addOption("step", true, "");
options.addOption("addr", true, "");
options.addOption("delimiter", true, "");
options.addOption("t", "temp", true, "");
return options;
}
项目:aliyun-oss-hadoop-fs
文件:TestGenericOptionsParser.java
/**
* Test that options passed to the constructor are used.
*/
@SuppressWarnings("static-access")
public void testCreateWithOptions() throws Exception {
// Create new option newOpt
Option opt = OptionBuilder.withArgName("int")
.hasArg()
.withDescription("A new option")
.create("newOpt");
Options opts = new Options();
opts.addOption(opt);
// Check newOpt is actually used to parse the args
String[] args = new String[2];
args[0] = "--newOpt";
args[1] = "7";
GenericOptionsParser g = new GenericOptionsParser(opts, args);
assertEquals("New option was ignored",
"7", g.getCommandLine().getOptionValues("newOpt")[0]);
}
项目:topicrawler
文件:ListServices.java
/**
*
*/
public ListServices(String[] args) {
Options opts = new Options();
opts.addOption(OptionBuilder.withLongOpt("help").withDescription("Display help message.").create("?"));
opts.addOption(OptionBuilder.withLongOpt("host").withArgName("hostname").hasArg().withDescription("specifies the hostname on which the rmi registry listens (default: localhost)").create("h"));
opts.addOption(OptionBuilder.withLongOpt("port").withArgName("port-number").hasArg().withDescription(String.format("specifies the port on which rmi registry listens (default: %d)", Registry.REGISTRY_PORT)).create("p"));
try {
CommandLine cmd = new ExtendedGnuParser(true).parse(opts, args);
if (cmd.hasOption("help"))
CliUtils.print_usage_quit(StartLM.class.getSimpleName(), opts, null, 0);
_port = Integer.parseInt(cmd.getOptionValue("port", String.valueOf(Registry.REGISTRY_PORT)));
_host = cmd.getOptionValue("host", "localhost");
} catch (Exception e) {
LOG.error("{}: {}", e.getClass().getSimpleName(), e.getMessage());
CliUtils.print_usage_quit(StartLM.class.getSimpleName(), opts, String.format("%s: %s%n", e.getClass().getSimpleName(), e.getMessage()), 1);
}
}
项目:topicrawler
文件:StartRMI.java
@SuppressWarnings("static-access")
public StartRMI(String[] args) {
LOG.warn("This main is only for convencience and might be deprectated soon. Consider using {}.", StartLM.class.getName());
Options opts = new Options();
opts.addOption(OptionBuilder.withLongOpt("help").withDescription("Display help message.").create("?"));
opts.addOption(OptionBuilder.withLongOpt("port").withArgName("port-number").hasArg().withDescription(String.format("specifies the port on which rmi registry listens (default: %d)", Registry.REGISTRY_PORT)).create("p"));
try {
CommandLine cmd = new ExtendedGnuParser(true).parse(opts, args);
if (cmd.hasOption("help"))
CliUtils.print_usage_quit(System.err, StartLM.class.getSimpleName(), opts, USAGE_HEADER, null, 0);
_port = Integer.parseInt(cmd.getOptionValue("port", String.valueOf(Registry.REGISTRY_PORT)));
} catch (Exception e) {
LOG.error("{}: {}", e.getClass().getSimpleName(), e.getMessage());
CliUtils.print_usage_quit(System.err, StartLM.class.getSimpleName(), opts, USAGE_HEADER, String.format("%s: %s%n", e.getClass().getSimpleName(), e.getMessage()), 1);
}
}
项目:topicrawler
文件:CliTest.java
@SuppressWarnings("static-access")
public static void main(String[] args) {
Options opts = new Options();
opts.addOption(new Option("?", "help", false, "display this message"));
opts.addOption(OptionBuilder.withLongOpt("host").withArgName("hostname").hasArgs(1).withDescription("specifies the hostname (default: localhost)").create("h"));
opts.addOption(OptionBuilder.withLongOpt("port").withArgName("port-number").hasArg().withDescription("specifies the port (default: 0, which means a random port)").create("p"));
opts.addOption(OptionBuilder.withLongOpt("dir").withArgName("directory").isRequired().hasArg().withDescription("specify the directory that contains '.txt' files that are used as source for this language model").create("d"));
opts.addOption(OptionBuilder.withLongOpt("parallel").withArgName("num-threads").hasArg().withDescription("specify number of parallel threads").create());
opts.addOption(OptionBuilder.withLongOpt("").hasArg().create());
try {
CommandLine cmd = new ExtendedGnuParser(true).parse(opts, args);
if (cmd.hasOption("help"))
CliUtils.print_usage(System.err, CliTest.class.getSimpleName(), opts, USAGE_HEADER, null);
Map<String, String> map = CliUtils.getOptionsMap(cmd.getOptions());
System.out.println(map);
} catch (Exception e) {
LOG.error("{}: {}", e.getClass().getSimpleName(), e.getMessage());
CliUtils.print_usage(System.err, CliTest.class.getSimpleName(), opts, USAGE_HEADER, String.format("%s: %s%n", e.getClass().getSimpleName(), e.getMessage()));
}
}
项目:ipst
文件:UncertaintiesAnalysisCommand.java
@Override
@SuppressWarnings("static-access")
public Options getOptions() {
Options options = new Options();
options.addOption(Option.builder().longOpt("case-file")
.desc("the case path")
.hasArg()
.argName("FILE")
.required()
.build());
options.addOption(OptionBuilder.withLongOpt("output-dir")
.withDescription("output directory path")
.hasArg()
.withArgName("DIR")
.isRequired()
.create());
options.addOption(OptionBuilder.withLongOpt("history-interval")
.withDescription("history time interval (example 2013-01-01T00:00:00+01:00/2013-01-31T23:59:00+01:00)")
.hasArg()
.withArgName("DATE1/DATE2")
.isRequired()
.create());
return options;
}
项目:ipst
文件:RunFPFTool.java
@Override
public Options getOptions() {
Options options = new Options();
options.addOption(OptionBuilder.withLongOpt("analysis")
.withDescription("the analysis id")
.hasArg()
.withArgName("ID")
.create());
options.addOption(OptionBuilder.withLongOpt("time-horizon")
.withDescription("time horizon (example DACF)")
.hasArg()
.withArgName("TH")
.create());
options.addOption(OptionBuilder.withLongOpt("base-case-date")
.withDescription("base case date (example 2013-01-15T18:45:00+01:00)")
.hasArg()
.withArgName("DATE")
.create());
options.addOption(OptionBuilder.withLongOpt("output-dir")
.withDescription("output dir where the FPF output files will be stored")
.hasArg()
.isRequired()
.withArgName("OUTPUTDIR")
.create());
return options;
}
项目:atmosphere-commons
文件:AbstractCliOptionsBuilder.java
/**
* Builds a {@link Option CLI Option} from the passed {@link IOption}.
*
* @param iOption
* - {@link IOption} object that will be used to build the {@link Option CLI Option}
* @return a {@link Option CLI Option} built from the passed AgentOption
*/
@SuppressWarnings("static-access")
protected Option buildOption(IOption iOption) {
CommandLineOption clOption = iOption.getOption();
Option cliOption = OptionBuilder.withLongOpt(clOption.getLongName())
.isRequired(clOption.isRequired())
.hasArg(iOption.hasArgument())
.withDescription(clOption.getDescritpion())
.create(clOption.getShortName());
if (iOption.hasArgument()) {
CommandLineArgument clArgument = iOption.getArgument();
cliOption.setArgName(clArgument.getName());
}
return cliOption;
}
项目:jqa-commandline-tool
文件:AbstractTask.java
@Override
public List<Option> getOptions() {
final List<Option> options = new ArrayList<>();
options.add(OptionBuilder.withArgName(CMDLINE_OPTION_S).withLongOpt(CMDLINE_OPTION_STORE_DIRECTORY)
.withDescription("The location of the Neo4j database. Deprecated, use '" + CMDLINE_OPTION_STORE_URI + "' instead.").hasArgs()
.create(CMDLINE_OPTION_S));
options.add(OptionBuilder.withArgName(CMDLINE_OPTION_STORE_URI)
.withDescription("The URI of the Neo4j database, e.g. 'file:jqassistant/store' or 'bolt://localhost:7687'.").hasArgs()
.create(CMDLINE_OPTION_STORE_URI));
options.add(OptionBuilder.withArgName(CMDLINE_OPTION_STORE_USERNAME).withDescription("The user name for connecting to Neo4j database.").hasArgs()
.create(CMDLINE_OPTION_STORE_USERNAME));
options.add(OptionBuilder.withArgName(CMDLINE_OPTION_STORE_PASSWORD).withDescription("The password for connecting to Neo4j database.").hasArgs()
.create(CMDLINE_OPTION_STORE_PASSWORD));
addTaskOptions(options);
return options;
}
项目:jqa-commandline-tool
文件:AnalyzeTask.java
@Override
protected void addTaskOptions(final List<Option> options) {
super.addTaskOptions(options);
options.add(OptionBuilder.withArgName(CMDLINE_OPTION_RULEPARAMETERS).withDescription("The name of a properties file providing rule parameters.")
.hasArgs().create(CMDLINE_OPTION_RULEPARAMETERS));
options.add(OptionBuilder.withArgName(CMDLINE_OPTION_REPORTDIR).withDescription("The directory for writing reports.").hasArgs()
.create(CMDLINE_OPTION_REPORTDIR));
options.add(OptionBuilder.withArgName(CMDLINE_OPTION_SEVERITY)
.withDescription("The severity threshold to report a failure. Deprecated: please use " + CMDLINE_OPTION_FAIL_ON_SEVERITY + " instead.")
.hasArgs().create(CMDLINE_OPTION_SEVERITY));
options.add(OptionBuilder.withArgName(CMDLINE_OPTION_FAIL_ON_SEVERITY)
.withDescription("The severity threshold to fail on rule violations, i.e. to exit with an error code.").hasArgs()
.create(CMDLINE_OPTION_FAIL_ON_SEVERITY));
options.add(OptionBuilder.withArgName(CMDLINE_OPTION_WARN_ON_SEVERITY)
.withDescription("The severity threshold to warn on rule violations.").hasArgs().create(CMDLINE_OPTION_WARN_ON_SEVERITY));
options.add(OptionBuilder.withArgName(CMDLINE_OPTION_EXECUTEAPPLIEDCONCEPTS)
.withDescription("If set also execute concepts which have already been applied.").create(CMDLINE_OPTION_EXECUTEAPPLIEDCONCEPTS));
}
项目:jqa-commandline-tool
文件:AbstractAnalyzeTask.java
@Override
protected void addTaskOptions(List<Option> options) {
options.add(OptionBuilder.withArgName(CMDLINE_OPTION_R).withLongOpt(CMDLINE_OPTION_RULEDIRECTORY).withDescription("The directory containing rules.")
.hasArgs().create(CMDLINE_OPTION_R));
options.add(OptionBuilder.withArgName(CMDLINE_OPTION_RULESURL).withDescription("The URL of a file containing rules.").hasArgs()
.create(CMDLINE_OPTION_RULESURL));
options.add(OptionBuilder.withArgName(CMDLINE_OPTION_GROUPS).withDescription("The groups to execute (default='default').").withValueSeparator(',')
.hasArgs().create(CMDLINE_OPTION_GROUPS));
options.add(OptionBuilder.withArgName(CMDLINE_OPTION_CONSTRAINTS).withDescription("The constraints to verify.").withValueSeparator(',').hasArgs()
.create(CMDLINE_OPTION_CONSTRAINTS));
options.add(OptionBuilder.withArgName(CMDLINE_OPTION_CONCEPTS).withDescription("The concepts to apply.").withValueSeparator(',').hasArgs()
.create(CMDLINE_OPTION_CONCEPTS));
options.add(OptionBuilder.withArgName(CMDLINE_OPTION_DEFAULT_GROUP_SEVERITY).withDescription("The default severity for groups.").withValueSeparator(',').hasArgs()
.create(CMDLINE_OPTION_DEFAULT_GROUP_SEVERITY));
options.add(OptionBuilder.withArgName(CMDLINE_OPTION_DEFAULT_CONCEPT_SEVERITY).withDescription("The default severity for concepts.").withValueSeparator(',').hasArgs()
.create(CMDLINE_OPTION_DEFAULT_CONCEPT_SEVERITY));
options.add(OptionBuilder.withArgName(CMDLINE_OPTION_DEFAULT_CONSTRAINT_SEVERITY).withDescription("The default severity for constraints.").withValueSeparator(',').hasArgs()
.create(CMDLINE_OPTION_DEFAULT_CONSTRAINT_SEVERITY));
}
项目:big-c
文件:OfflineEditsViewer.java
/**
* Build command-line options and descriptions
*
* @return command line options
*/
public static Options buildOptions() {
Options options = new Options();
// Build in/output file arguments, which are required, but there is no
// addOption method that can specify this
OptionBuilder.isRequired();
OptionBuilder.hasArgs();
OptionBuilder.withLongOpt("outputFilename");
options.addOption(OptionBuilder.create("o"));
OptionBuilder.isRequired();
OptionBuilder.hasArgs();
OptionBuilder.withLongOpt("inputFilename");
options.addOption(OptionBuilder.create("i"));
options.addOption("p", "processor", true, "");
options.addOption("v", "verbose", false, "");
options.addOption("f", "fix-txids", false, "");
options.addOption("r", "recover", false, "");
options.addOption("h", "help", false, "");
return options;
}
项目:big-c
文件:OfflineImageViewer.java
/**
* Build command-line options and descriptions
*/
public static Options buildOptions() {
Options options = new Options();
// Build in/output file arguments, which are required, but there is no
// addOption method that can specify this
OptionBuilder.isRequired();
OptionBuilder.hasArgs();
OptionBuilder.withLongOpt("outputFile");
options.addOption(OptionBuilder.create("o"));
OptionBuilder.isRequired();
OptionBuilder.hasArgs();
OptionBuilder.withLongOpt("inputFile");
options.addOption(OptionBuilder.create("i"));
options.addOption("p", "processor", true, "");
options.addOption("h", "help", false, "");
options.addOption("skipBlocks", false, "");
options.addOption("printToScreen", false, "");
options.addOption("delimiter", true, "");
return options;
}
项目:big-c
文件:OfflineImageViewerPB.java
/**
* Build command-line options and descriptions
*/
private static Options buildOptions() {
Options options = new Options();
// Build in/output file arguments, which are required, but there is no
// addOption method that can specify this
OptionBuilder.isRequired();
OptionBuilder.hasArgs();
OptionBuilder.withLongOpt("inputFile");
options.addOption(OptionBuilder.create("i"));
options.addOption("o", "outputFile", true, "");
options.addOption("p", "processor", true, "");
options.addOption("h", "help", false, "");
options.addOption("maxSize", true, "");
options.addOption("step", true, "");
options.addOption("addr", true, "");
options.addOption("delimiter", true, "");
options.addOption("t", "temp", true, "");
return options;
}
项目:big-c
文件:TestGenericOptionsParser.java
/**
* Test that options passed to the constructor are used.
*/
@SuppressWarnings("static-access")
public void testCreateWithOptions() throws Exception {
// Create new option newOpt
Option opt = OptionBuilder.withArgName("int")
.hasArg()
.withDescription("A new option")
.create("newOpt");
Options opts = new Options();
opts.addOption(opt);
// Check newOpt is actually used to parse the args
String[] args = new String[2];
args[0] = "--newOpt";
args[1] = "7";
GenericOptionsParser g = new GenericOptionsParser(opts, args);
assertEquals("New option was ignored",
"7", g.getCommandLine().getOptionValues("newOpt")[0]);
}
项目:infotranspub-backend
文件:BasicOption.java
public void addToOptionList(Options optionList){
if (hasLongOption() ){
if (hasShortOption()) {
optionList.addOption( getShortOption(), getLongOption(),hasArg(), getDescription() );
} else {
if (hasArg()) {
optionList.addOption( OptionBuilder.withLongOpt(getLongOption())
.hasArg()
.withValueSeparator()
.withDescription(getDescription())
.create());
} else {
optionList.addOption( OptionBuilder.withLongOpt(getLongOption())
.withDescription(getDescription())
.create());
}
}
} else if (hasShortOption()) {
optionList.addOption( getShortOption(), hasArg(), getDescription() );
}
}
项目:mesfavoris
文件:BugCLI13Test.java
@Test
public void testCLI13() throws ParseException
{
final String debugOpt = "debug";
@SuppressWarnings("static-access")
Option debug = OptionBuilder
.withArgName( debugOpt )
.withDescription( "turn on debugging" )
.withLongOpt( debugOpt )
.hasArg()
.create( 'd' );
Options options = new Options();
options.addOption( debug );
CommandLine commandLine = new PosixParser().parse( options, new String[]{"-d", "true"} );
assertEquals("true", commandLine.getOptionValue( debugOpt ));
assertEquals("true", commandLine.getOptionValue( 'd' ));
assertTrue(commandLine.hasOption( 'd'));
assertTrue(commandLine.hasOption( debugOpt));
}
项目:mesfavoris
文件:BugCLI13Test.java
@Test
public void testCLI13() throws ParseException
{
final String debugOpt = "debug";
@SuppressWarnings("static-access")
Option debug = OptionBuilder
.withArgName( debugOpt )
.withDescription( "turn on debugging" )
.withLongOpt( debugOpt )
.hasArg()
.create( 'd' );
Options options = new Options();
options.addOption( debug );
CommandLine commandLine = new PosixParser().parse( options, new String[]{"-d", "true"} );
assertEquals("true", commandLine.getOptionValue( debugOpt ));
assertEquals("true", commandLine.getOptionValue( 'd' ));
assertTrue(commandLine.hasOption( 'd'));
assertTrue(commandLine.hasOption( debugOpt));
}
项目:geomesa-tutorials
文件:GDELTIngest.java
public static void main(String [ ] args) throws Exception {
CommandLineParser parser = new BasicParser();
Options options = getCommonRequiredOptions();
Option ingestFileOpt = OptionBuilder.withArgName(INGEST_FILE)
.hasArg()
.isRequired()
.withDescription("ingest tsv file on hdfs")
.create(INGEST_FILE);
options.addOption(ingestFileOpt);
CommandLine cmd = parser.parse( options, args);
Map<String, String> dsConf = getAccumuloDataStoreConf(cmd);
String featureName = cmd.getOptionValue(FEATURE_NAME);
SimpleFeatureType featureType = buildGDELTFeatureType(featureName);
DataStore ds = DataStoreFinder.getDataStore(dsConf);
ds.createSchema(featureType);
runMapReduceJob(featureName,
dsConf,
new Path(cmd.getOptionValue(INGEST_FILE)));
}
项目:geomesa-tutorials
文件:KafkaListener.java
public static Options getCommonRequiredOptions() {
Options options = new Options();
Option kafkaBrokers = OptionBuilder.withArgName("brokers")
.hasArg()
.isRequired()
.withDescription("The comma-separated list of Kafka brokers, e.g. localhost:9092")
.create("brokers");
options.addOption(kafkaBrokers);
Option zookeepers = OptionBuilder.withArgName("zookeepers")
.hasArg()
.isRequired()
.withDescription("The comma-separated list of Zookeeper nodes that support your Kafka instance, e.g.: zoo1:2181,zoo2:2181,zoo3:2181")
.create("zookeepers");
options.addOption(zookeepers);
Option zkPath = OptionBuilder.withArgName("zkPath")
.hasArg()
.withDescription("Zookeeper's discoverable path for metadata, defaults to /geomesa/ds/kafka")
.create("zkPath");
options.addOption(zkPath);
return options;
}
项目:geomesa-tutorials
文件:SetupUtil.java
static Options getWfsOptions() {
Options options = new Options();
Option geoserver = OptionBuilder.withArgName(GEOSERVER_URL)
.hasArg()
.isRequired()
.withDescription(
"the base url to geoserver e.g: https://localhost:8443/geoserver/")
.create(GEOSERVER_URL);
options.addOption(geoserver);
Option timeout = OptionBuilder.withArgName(TIMEOUT)
.hasArg()
.withDescription(
"the HTTP connection timeout, in milliseconds")
.create(TIMEOUT);
options.addOption(timeout);
options.addOption(OptionBuilder.withArgName(FEATURE_STORE).hasArg().isRequired()
.withDescription(
"the geoserver store containing the GDELT data. Needs to be identified by <workspace>:<name>, e.g. 'geomesa:gdelt'")
.create(FEATURE_STORE));
return options;
}
项目:mesfavoris
文件:BugCLI13Test.java
@Test
public void testCLI13() throws ParseException
{
final String debugOpt = "debug";
@SuppressWarnings("static-access")
Option debug = OptionBuilder
.withArgName( debugOpt )
.withDescription( "turn on debugging" )
.withLongOpt( debugOpt )
.hasArg()
.create( 'd' );
Options options = new Options();
options.addOption( debug );
CommandLine commandLine = new PosixParser().parse( options, new String[]{"-d", "true"} );
assertEquals("true", commandLine.getOptionValue( debugOpt ));
assertEquals("true", commandLine.getOptionValue( 'd' ));
assertTrue(commandLine.hasOption( 'd'));
assertTrue(commandLine.hasOption( debugOpt));
}
项目:mesfavoris
文件:BugCLI13Test.java
@Test
public void testCLI13() throws ParseException
{
final String debugOpt = "debug";
@SuppressWarnings("static-access")
Option debug = OptionBuilder
.withArgName( debugOpt )
.withDescription( "turn on debugging" )
.withLongOpt( debugOpt )
.hasArg()
.create( 'd' );
Options options = new Options();
options.addOption( debug );
CommandLine commandLine = new PosixParser().parse( options, new String[]{"-d", "true"} );
assertEquals("true", commandLine.getOptionValue( debugOpt ));
assertEquals("true", commandLine.getOptionValue( 'd' ));
assertTrue(commandLine.hasOption( 'd'));
assertTrue(commandLine.hasOption( debugOpt));
}
项目:metanome-algorithms
文件:CLIParserBenchmarker.java
@SuppressWarnings("static-access")
public CLIParserBenchmarker() {
Options options = new Options();
Option inputDirectory = OptionBuilder.withArgName("input")
.hasArg()
.withDescription("Benchmark files directory.")
.create("input");
Option miner = OptionBuilder.withArgName("miner")
.hasArg()
.withDescription("Miner: tane, fastfds, fdiscminer.")
.create("miner");
Option delimiter = OptionBuilder.withArgName("delimiter")
.hasArg()
.withDescription("Delimiter of input files.")
.create("delimiter");
Option xmxForMiner = OptionBuilder.withArgName("xmx")
.hasArg()
.withDescription("Maximum heap space for miner.")
.create("xmx");
Option timeout = OptionBuilder.withArgName("timeout")
.hasArg()
.withDescription("Maximum calculation time for miner.")
.create("timeout");
Option allFiles = new Option("all", false, "Use all files in directory.");
options.addOption(inputDirectory);
options.addOption(miner);
options.addOption(delimiter);
options.addOption(xmxForMiner);
options.addOption(timeout);
options.addOption(allFiles);
this.setOptions(options);
}
项目:metanome-algorithms
文件:CLIParserMiner.java
@SuppressWarnings("static-access")
public CLIParserMiner() {
Options options = new Options();
Option inputFileName = OptionBuilder.withArgName("file")
.hasArg()
.withDescription("Input file name.")
.create("file");
Option inputDirectory = OptionBuilder.withArgName("input")
.hasArg()
.withDescription("Column files directory.")
.create("input");
Option resultFile = OptionBuilder.withArgName("result")
.hasArg()
.withDescription("Result file.")
.create("result");
Option numberOfColumns = OptionBuilder.withArgName("columns")
.hasArg()
.withDescription("Number of columns.")
.create("columns");
Option numberOfRows = OptionBuilder.withArgName("rows")
.hasArg()
.withDescription("Number of rows.")
.create("rows");
options.addOption(inputFileName);
options.addOption(inputDirectory);
options.addOption(resultFile);
options.addOption(numberOfColumns);
options.addOption(numberOfRows);
this.setOptions(options);
}