本文整理了Java中joptsimple.ArgumentAcceptingOptionSpec.required()
方法的一些代码示例,展示了ArgumentAcceptingOptionSpec.required()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ArgumentAcceptingOptionSpec.required()
方法的具体详情如下:
包路径:joptsimple.ArgumentAcceptingOptionSpec
类名称:ArgumentAcceptingOptionSpec
方法名:required
[英]Marks this option as required. An OptionException will be thrown when OptionParser#parse(java.lang.String...) is called, if an option is marked as required and not specified on the command line.
[中]根据需要标记此选项。OptionParser#parse(java.lang.String…)时将引发OptionException如果选项标记为必需且未在命令行上指定,则调用。
代码示例来源:origin: oldmanpushcart/greys-anatomy
private Configure analyzeConfigure(String[] args) {
final OptionParser parser = new OptionParser();
parser.accepts("pid").withRequiredArg().ofType(int.class).required();
parser.accepts("target").withOptionalArg().ofType(String.class);
parser.accepts("multi").withOptionalArg().ofType(int.class);
parser.accepts("core").withOptionalArg().ofType(String.class);
parser.accepts("agent").withOptionalArg().ofType(String.class);
final OptionSet os = parser.parse(args);
final Configure configure = new Configure();
if (os.has("target")) {
final String[] strSplit = ((String) os.valueOf("target")).split(":");
configure.setTargetIp(strSplit[0]);
configure.setTargetPort(Integer.valueOf(strSplit[1]));
}
configure.setJavaPid((Integer) os.valueOf("pid"));
configure.setGreysAgent((String) os.valueOf("agent"));
configure.setGreysCore((String) os.valueOf("core"));
return configure;
}
代码示例来源:origin: NGDATA/hbase-indexer
@Override
protected OptionParser setupOptionParser() {
OptionParser parser = super.setupOptionParser();
indexerConfOption.required();
return parser;
}
代码示例来源:origin: com.ngdata/hbase-indexer-cli
@Override
protected OptionParser setupOptionParser() {
OptionParser parser = super.setupOptionParser();
indexerConfOption.required();
return parser;
}
代码示例来源:origin: com.strapdata.elasticsearch/elasticsearch
public TruncateTranslogCommand() {
super("Truncates a translog to create a new, empty translog");
this.translogFolder = parser.acceptsAll(Arrays.asList("d", "dir"),
"Translog Directory location on disk")
.withRequiredArg()
.required();
this.batchMode = parser.acceptsAll(Arrays.asList("b", "batch"),
"Enable batch mode explicitly, automatic confirmation of warnings");
}
代码示例来源:origin: apache/servicemix-bundles
public TruncateTranslogCommand() {
super("Truncates a translog to create a new, empty translog");
this.translogFolder = parser.acceptsAll(Arrays.asList("d", "dir"),
"Translog Directory location on disk")
.withRequiredArg()
.required();
this.batchMode = parser.acceptsAll(Arrays.asList("b", "batch"),
"Enable batch mode explicitly, automatic confirmation of warnings");
}
代码示例来源:origin: NGDATA/hbase-indexer
@Override
protected OptionParser setupOptionParser() {
OptionParser parser = super.setupOptionParser();
nameOption = parser.acceptsAll(Lists.newArrayList("n", "name"), "a name for the index").withRequiredArg().ofType(
String.class).required();
return parser;
}
代码示例来源:origin: com.ngdata/hbase-indexer-cli
@Override
protected OptionParser setupOptionParser() {
OptionParser parser = super.setupOptionParser();
nameOption = parser.acceptsAll(Lists.newArrayList("n", "name"), "a name for the index").withRequiredArg().ofType(
String.class).required();
return parser;
}
代码示例来源:origin: org.apache.kafka/kafka_2.10
.ofType(String.class)
.describedAs("id")
.required();
bootstrapServerOption = optionParser.accepts("bootstrap-servers", "Comma-separated list of broker urls with format: HOST1:PORT1,HOST2:PORT2")
.withRequiredArg()
代码示例来源:origin: com.github.ansell.shp/utm2wgs
public static void main(String... args) throws Exception {
final OptionParser parser = new OptionParser();
final OptionSpec<Void> help = parser.accepts("help").forHelp();
final OptionSpec<Double> wgsLongitudeOpt = parser.acceptsAll(Arrays.asList("longitude"))
.withRequiredArg().ofType(Double.class).required().describedAs("The WGS Longitude");
final OptionSpec<Double> wgsLatitudeOpt = parser.acceptsAll(Arrays.asList("latitude"))
.withRequiredArg().ofType(Double.class).required().describedAs("The WGS Latitude");
OptionSet options = null;
try {
options = parser.parse(args);
} catch (final OptionException e) {
System.out.println(e.getMessage());
parser.printHelpOn(System.out);
throw e;
}
if (options.has(help)) {
parser.printHelpOn(System.out);
return;
}
UTM fromWGS = UTM.fromWGS84(wgsLatitudeOpt.value(options), wgsLongitudeOpt.value(options));
System.out.println(fromWGS.toString());
}
}
代码示例来源:origin: USPTO/PatentPublicData
public OptionParser buildArgs(OptionParser opParser) {
super.buildArgs();
opParser.accepts("xslt").withRequiredArg().ofType(String.class).describedAs("xslt stylesheet file path")
.required();
opParser.accepts("prettyPrint").withOptionalArg().ofType(Boolean.class).describedAs("Pretty print output")
.defaultsTo(false);
return opParser;
}
代码示例来源:origin: org.apache.kafka/kafka
.ofType(String.class)
.describedAs("id")
.required();
bootstrapServerOption = optionParser.accepts("bootstrap-servers", "Comma-separated list of broker urls with format: HOST1:PORT1,HOST2:PORT2")
.withRequiredArg()
代码示例来源:origin: org.apache.kafka/kafka_2.12
.ofType(String.class)
.describedAs("id")
.required();
bootstrapServerOption = optionParser.accepts("bootstrap-servers", "Comma-separated list of broker urls with format: HOST1:PORT1,HOST2:PORT2")
.withRequiredArg()
代码示例来源:origin: org.apache.kafka/kafka_2.11
.ofType(String.class)
.describedAs("id")
.required();
bootstrapServerOption = optionParser.accepts("bootstrap-servers", "Comma-separated list of broker urls with format: HOST1:PORT1,HOST2:PORT2")
.withRequiredArg()
代码示例来源:origin: hcoles/pitest
.describedAs("directory to create report folder in").required();
.describedAs(
"comma separated list of filters to match against classes to test")
.required();
.describedAs("comma separated list of source directories").required();
代码示例来源:origin: io.snappydata/gemfire-core
private void addJoptOptionObject(Option option) {
OptionSpecBuilder optionBuilder = null;
optionBuilder = parser.acceptsAll(option.getAggregate(),
option.getHelp());
/* Now set the the attributes related to the option */
ArgumentAcceptingOptionSpec<String> argumentSpecs = null;
if (option.isWithRequiredArgs()) {
argumentSpecs = optionBuilder.withRequiredArg();
} else {
argumentSpecs = optionBuilder.withOptionalArg();
}
if (option.isRequired()) {
argumentSpecs.required();
}
if (option.getValueSeparator() != null) {
argumentSpecs.withValuesSeparatedBy(option.getValueSeparator());
}
}
代码示例来源:origin: org.apache.geode/gemfire-core
private void addJoptOptionObject(Option option) {
OptionSpecBuilder optionBuilder = null;
optionBuilder = parser.acceptsAll(option.getAggregate(),
option.getHelp());
/* Now set the the attributes related to the option */
ArgumentAcceptingOptionSpec<String> argumentSpecs = null;
if (option.isWithRequiredArgs()) {
argumentSpecs = optionBuilder.withRequiredArg();
} else {
argumentSpecs = optionBuilder.withOptionalArg();
}
if (option.isRequired()) {
argumentSpecs.required();
}
if (option.getValueSeparator() != null) {
argumentSpecs.withValuesSeparatedBy(option.getValueSeparator());
}
}
代码示例来源:origin: USPTO/PatentPublicData
public static void main(String[] args) throws IOException {
OptionParser parser = new OptionParser() {
{
accepts("url").withRequiredArg().ofType(String.class).describedAs("url string").required();
accepts("dir").withOptionalArg().ofType(String.class).describedAs("download directory").defaultsTo("download");
}
};
OptionSet options = parser.parse(args);
String url = (String) options.valueOf("url");
String dir = (String) options.valueOf("dir");
Path downloadDir = Paths.get(dir);
DownloadFile downloader = new DownloadFile();
downloader.setup(downloadDir);
downloader.download(url, downloadDir);
}
代码示例来源:origin: USPTO/PatentPublicData
public OptionParser buildArgs(OptionParser opParser) {
super.buildArgs(opParser);
opParser.accepts("outDir").withRequiredArg().ofType(String.class).describedAs("Output Directory").required();
opParser.acceptsAll(asList("outBulk", "outputBulkFile")).withOptionalArg().ofType(Boolean.class)
.describedAs("Output bulk file, single file record per line").defaultsTo(true);
opParser.accepts("bulkRecLimit").withOptionalArg().ofType(Integer.class)
.describedAs("Limit of records per bulk file").defaultsTo(-1);
opParser.acceptsAll(asList("bulkKV", "bulkkv", "kv")).withOptionalArg().ofType(Boolean.class)
.describedAs("Prepend each record with docid ; DOC_ID<TAB>RECORD").defaultsTo(false);
opParser.accepts("prettyPrint").withOptionalArg().ofType(Boolean.class).describedAs("Pretty Print JSON")
.defaultsTo(false);
opParser.accepts("type").withOptionalArg().ofType(String.class)
.describedAs("types options: [raw,xml,json,json_flat,patft,object,text]").defaultsTo("json");
return opParser;
}
代码示例来源:origin: joliciel-informatique/talismane
public static void main(String[] args) throws Exception {
OptionParser parser = new OptionParser();
OptionSpec<Integer> exampleOption = parser.accepts("example", "which example to run").withRequiredArg().ofType(Integer.class);
OptionSpec<String> sessionIdOption = parser.accepts("sessionId", "the current session id - configuration read as talismane.core.[sessionId]")
.withRequiredArg().required().ofType(String.class);
if (args.length <= 1) {
parser.printHelpOn(System.out);
return;
}
OptionSet options = parser.parse(args);
int example = 1;
if (options.has(exampleOption)) {
example = options.valueOf(exampleOption);
}
String sessionId = options.valueOf(sessionIdOption);
if (example == 1)
example1(sessionId);
else
example2(sessionId);
}
代码示例来源:origin: USPTO/PatentPublicData
public OptionParser buildArgs(OptionParser opParser) {
super.buildArgs(opParser);
opParser.accepts("outDir").withOptionalArg().ofType(String.class).describedAs("directory")
.defaultsTo("download");
opParser.accepts("fetch-type").withRequiredArg().ofType(String.class)
.describedAs("Patent Document Type [grant, application, gazette] ; type=? will show available types.")
.required();
opParser.accepts("fetch-date").withRequiredArg().ofType(String.class)
.describedAs("Single Date Range or list, example: 20150801-20150901,20160501-20160601").required();
opParser.accepts("fetch-limit").withOptionalArg().ofType(Integer.class)
.describedAs("download file limit ; 0 is unlimited").defaultsTo(0);
opParser.accepts("fetch-async").withOptionalArg().ofType(Boolean.class).describedAs("download file async")
.defaultsTo(false);
opParser.accepts("fetch-filename").withOptionalArg().ofType(String.class)
.describedAs("comma separated list of file names to match and download");
opParser.accepts("fetch-delete").withOptionalArg().ofType(Boolean.class)
.describedAs("Delete bulkfile after each processing download.").defaultsTo(false);
opParser.accepts("restart").withOptionalArg().ofType(Boolean.class)
.describedAs("Restart failed download from job file in download directory.").defaultsTo(false);
return opParser;
}
内容来源于网络,如有侵权,请联系作者删除!