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; }
@Override protected OptionParser setupOptionParser() { OptionParser parser = super.setupOptionParser(); indexerConfOption.required(); return parser; }
@Override protected OptionParser setupOptionParser() { OptionParser parser = super.setupOptionParser(); indexerConfOption.required(); return parser; }
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"); }
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"); }
@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; }
@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; }
.ofType(String.class) .describedAs("id") .required(); bootstrapServerOption = optionParser.accepts("bootstrap-servers", "Comma-separated list of broker urls with format: HOST1:PORT1,HOST2:PORT2") .withRequiredArg()
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()); } }
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; }
.ofType(String.class) .describedAs("id") .required(); bootstrapServerOption = optionParser.accepts("bootstrap-servers", "Comma-separated list of broker urls with format: HOST1:PORT1,HOST2:PORT2") .withRequiredArg()
.ofType(String.class) .describedAs("id") .required(); bootstrapServerOption = optionParser.accepts("bootstrap-servers", "Comma-separated list of broker urls with format: HOST1:PORT1,HOST2:PORT2") .withRequiredArg()
.ofType(String.class) .describedAs("id") .required(); bootstrapServerOption = optionParser.accepts("bootstrap-servers", "Comma-separated list of broker urls with format: HOST1:PORT1,HOST2:PORT2") .withRequiredArg()
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()); } }
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()); } }
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); }
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; }
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); }
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; }