List of usage examples for org.apache.commons.cli Option setArgs
public void setArgs(int num)
From source file:edu.nyu.vida.data_polygamy.relationship_computation.Relationship.java
/** * @param args//from w ww.ja v a 2 s. c o m * @throws ParseException */ @SuppressWarnings({ "deprecation" }) public static void main(String[] args) throws IOException, InterruptedException, ClassNotFoundException { Options options = new Options(); Option forceOption = new Option("f", "force", false, "force the computation of the relationship " + "even if files already exist"); forceOption.setRequired(false); options.addOption(forceOption); Option scoreOption = new Option("sc", "score", true, "set threhsold for relationship score"); scoreOption.setRequired(false); scoreOption.setArgName("SCORE THRESHOLD"); options.addOption(scoreOption); Option strengthOption = new Option("st", "strength", true, "set threhsold for relationship strength"); strengthOption.setRequired(false); strengthOption.setArgName("STRENGTH THRESHOLD"); options.addOption(strengthOption); Option completeRandomizationOption = new Option("c", "complete-randomization", false, "use complete randomization when performing significance tests"); completeRandomizationOption.setRequired(false); options.addOption(completeRandomizationOption); Option idOption = new Option("id", "ids", false, "output id instead of names for datasets and attributes"); idOption.setRequired(false); options.addOption(idOption); Option g1Option = new Option("g1", "first-group", true, "set first group of datasets"); g1Option.setRequired(true); g1Option.setArgName("FIRST GROUP"); g1Option.setArgs(Option.UNLIMITED_VALUES); options.addOption(g1Option); Option g2Option = new Option("g2", "second-group", true, "set second group of datasets"); g2Option.setRequired(false); g2Option.setArgName("SECOND GROUP"); g2Option.setArgs(Option.UNLIMITED_VALUES); options.addOption(g2Option); Option machineOption = new Option("m", "machine", true, "machine identifier"); machineOption.setRequired(true); machineOption.setArgName("MACHINE"); machineOption.setArgs(1); options.addOption(machineOption); Option nodesOption = new Option("n", "nodes", true, "number of nodes"); nodesOption.setRequired(true); nodesOption.setArgName("NODES"); nodesOption.setArgs(1); options.addOption(nodesOption); Option s3Option = new Option("s3", "s3", false, "data on Amazon S3"); s3Option.setRequired(false); options.addOption(s3Option); Option awsAccessKeyIdOption = new Option("aws_id", "aws-id", true, "aws access key id; " + "this is required if the execution is on aws"); awsAccessKeyIdOption.setRequired(false); awsAccessKeyIdOption.setArgName("AWS-ACCESS-KEY-ID"); awsAccessKeyIdOption.setArgs(1); options.addOption(awsAccessKeyIdOption); Option awsSecretAccessKeyOption = new Option("aws_key", "aws-id", true, "aws secrect access key; " + "this is required if the execution is on aws"); awsSecretAccessKeyOption.setRequired(false); awsSecretAccessKeyOption.setArgName("AWS-SECRET-ACCESS-KEY"); awsSecretAccessKeyOption.setArgs(1); options.addOption(awsSecretAccessKeyOption); Option bucketOption = new Option("b", "s3-bucket", true, "bucket on s3; " + "this is required if the execution is on aws"); bucketOption.setRequired(false); bucketOption.setArgName("S3-BUCKET"); bucketOption.setArgs(1); options.addOption(bucketOption); Option helpOption = new Option("h", "help", false, "display this message"); helpOption.setRequired(false); options.addOption(helpOption); Option removeOption = new Option("r", "remove-not-significant", false, "remove relationships that are not" + "significant from the final output"); removeOption.setRequired(false); options.addOption(removeOption); HelpFormatter formatter = new HelpFormatter(); CommandLineParser parser = new PosixParser(); CommandLine cmd = null; try { cmd = parser.parse(options, args); } catch (ParseException e) { formatter.printHelp("hadoop jar data-polygamy.jar " + "edu.nyu.vida.data_polygamy.relationship_computation.Relationship", options, true); System.exit(0); } if (cmd.hasOption("h")) { formatter.printHelp("hadoop jar data-polygamy.jar " + "edu.nyu.vida.data_polygamy.relationship_computation.Relationship", options, true); System.exit(0); } boolean s3 = cmd.hasOption("s3"); String s3bucket = ""; String awsAccessKeyId = ""; String awsSecretAccessKey = ""; if (s3) { if ((!cmd.hasOption("aws_id")) || (!cmd.hasOption("aws_key")) || (!cmd.hasOption("b"))) { System.out.println( "Arguments 'aws_id', 'aws_key', and 'b'" + " are mandatory if execution is on AWS."); formatter.printHelp( "hadoop jar data-polygamy.jar " + "edu.nyu.vida.data_polygamy.relationship_computation.Relationship", options, true); System.exit(0); } s3bucket = cmd.getOptionValue("b"); awsAccessKeyId = cmd.getOptionValue("aws_id"); awsSecretAccessKey = cmd.getOptionValue("aws_key"); } boolean snappyCompression = false; boolean bzip2Compression = false; String machine = cmd.getOptionValue("m"); int nbNodes = Integer.parseInt(cmd.getOptionValue("n")); Configuration s3conf = new Configuration(); if (s3) { s3conf.set("fs.s3.awsAccessKeyId", awsAccessKeyId); s3conf.set("fs.s3.awsSecretAccessKey", awsSecretAccessKey); s3conf.set("bucket", s3bucket); } Path path = null; FileSystem fs = FileSystem.get(new Configuration()); ArrayList<String> shortDataset = new ArrayList<String>(); ArrayList<String> firstGroup = new ArrayList<String>(); ArrayList<String> secondGroup = new ArrayList<String>(); HashMap<String, String> datasetAgg = new HashMap<String, String>(); boolean removeNotSignificant = cmd.hasOption("r"); boolean removeExistingFiles = cmd.hasOption("f"); boolean completeRandomization = cmd.hasOption("c"); boolean hasScoreThreshold = cmd.hasOption("sc"); boolean hasStrengthThreshold = cmd.hasOption("st"); boolean outputIds = cmd.hasOption("id"); String scoreThreshold = hasScoreThreshold ? cmd.getOptionValue("sc") : ""; String strengthThreshold = hasStrengthThreshold ? cmd.getOptionValue("st") : ""; // all datasets ArrayList<String> all_datasets = new ArrayList<String>(); if (s3) { path = new Path(s3bucket + FrameworkUtils.datasetsIndexDir); fs = FileSystem.get(path.toUri(), s3conf); } else { path = new Path(fs.getHomeDirectory() + "/" + FrameworkUtils.datasetsIndexDir); } BufferedReader br = new BufferedReader(new InputStreamReader(fs.open(path))); String line = br.readLine(); while (line != null) { all_datasets.add(line.split("\t")[0]); line = br.readLine(); } br.close(); if (s3) fs.close(); String[] all_datasets_array = new String[all_datasets.size()]; all_datasets.toArray(all_datasets_array); String[] firstGroupCmd = cmd.getOptionValues("g1"); String[] secondGroupCmd = cmd.hasOption("g2") ? cmd.getOptionValues("g2") : all_datasets_array; addDatasets(firstGroupCmd, firstGroup, shortDataset, datasetAgg, path, fs, s3conf, s3, s3bucket); addDatasets(secondGroupCmd, secondGroup, shortDataset, datasetAgg, path, fs, s3conf, s3, s3bucket); if (shortDataset.size() == 0) { System.out.println("No datasets to process."); System.exit(0); } if (firstGroup.isEmpty()) { System.out.println("No indices from datasets in G1."); System.exit(0); } if (secondGroup.isEmpty()) { System.out.println("No indices from datasets in G2."); System.exit(0); } // getting dataset ids String datasetNames = ""; String datasetIds = ""; HashMap<String, String> datasetId = new HashMap<String, String>(); Iterator<String> it = shortDataset.iterator(); while (it.hasNext()) { datasetId.put(it.next(), null); } if (s3) { path = new Path(s3bucket + FrameworkUtils.datasetsIndexDir); fs = FileSystem.get(path.toUri(), s3conf); } else { path = new Path(fs.getHomeDirectory() + "/" + FrameworkUtils.datasetsIndexDir); } br = new BufferedReader(new InputStreamReader(fs.open(path))); line = br.readLine(); while (line != null) { String[] dt = line.split("\t"); all_datasets.add(dt[0]); if (datasetId.containsKey(dt[0])) { datasetId.put(dt[0], dt[1]); datasetNames += dt[0] + ","; datasetIds += dt[1] + ","; } line = br.readLine(); } br.close(); if (s3) fs.close(); datasetNames = datasetNames.substring(0, datasetNames.length() - 1); datasetIds = datasetIds.substring(0, datasetIds.length() - 1); it = shortDataset.iterator(); while (it.hasNext()) { String dataset = it.next(); if (datasetId.get(dataset) == null) { System.out.println("No dataset id for " + dataset); System.exit(0); } } String firstGroupStr = ""; String secondGroupStr = ""; for (String dataset : firstGroup) { firstGroupStr += datasetId.get(dataset) + ","; } for (String dataset : secondGroup) { secondGroupStr += datasetId.get(dataset) + ","; } firstGroupStr = firstGroupStr.substring(0, firstGroupStr.length() - 1); secondGroupStr = secondGroupStr.substring(0, secondGroupStr.length() - 1); String relationshipsDir = ""; if (outputIds) { relationshipsDir = FrameworkUtils.relationshipsIdsDir; } else { relationshipsDir = FrameworkUtils.relationshipsDir; } FrameworkUtils.createDir(s3bucket + relationshipsDir, s3conf, s3); String random = completeRandomization ? "complete" : "restricted"; String indexInputDirs = ""; String noRelationship = ""; HashSet<String> dirs = new HashSet<String>(); String dataset1; String dataset2; String datasetId1; String datasetId2; for (int i = 0; i < firstGroup.size(); i++) { for (int j = 0; j < secondGroup.size(); j++) { if (Integer.parseInt(datasetId.get(firstGroup.get(i))) < Integer .parseInt(datasetId.get(secondGroup.get(j)))) { dataset1 = firstGroup.get(i); dataset2 = secondGroup.get(j); } else { dataset1 = secondGroup.get(j); dataset2 = firstGroup.get(i); } datasetId1 = datasetId.get(dataset1); datasetId2 = datasetId.get(dataset2); if (dataset1.equals(dataset2)) continue; String correlationOutputFileName = s3bucket + relationshipsDir + "/" + dataset1 + "-" + dataset2 + "/"; if (removeExistingFiles) { FrameworkUtils.removeFile(correlationOutputFileName, s3conf, s3); } if (!FrameworkUtils.fileExists(correlationOutputFileName, s3conf, s3)) { dirs.add(s3bucket + FrameworkUtils.indexDir + "/" + dataset1); dirs.add(s3bucket + FrameworkUtils.indexDir + "/" + dataset2); } else { noRelationship += datasetId1 + "-" + datasetId2 + ","; } } } if (dirs.isEmpty()) { System.out.println("All the relationships were already computed."); System.out.println("Use -f in the beginning of the command line to force the computation."); System.exit(0); } for (String dir : dirs) { indexInputDirs += dir + ","; } Configuration conf = new Configuration(); Machine machineConf = new Machine(machine, nbNodes); String jobName = "relationship" + "-" + random; String relationshipOutputDir = s3bucket + relationshipsDir + "/tmp/"; FrameworkUtils.removeFile(relationshipOutputDir, s3conf, s3); for (int i = 0; i < shortDataset.size(); i++) { conf.set("dataset-" + datasetId.get(shortDataset.get(i)) + "-agg", datasetAgg.get(shortDataset.get(i))); } for (int i = 0; i < shortDataset.size(); i++) { conf.set("dataset-" + datasetId.get(shortDataset.get(i)) + "-agg-size", Integer.toString(datasetAgg.get(shortDataset.get(i)).split(",").length)); } conf.set("dataset-keys", datasetIds); conf.set("dataset-names", datasetNames); conf.set("first-group", firstGroupStr); conf.set("second-group", secondGroupStr); conf.set("complete-random", String.valueOf(completeRandomization)); conf.set("output-ids", String.valueOf(outputIds)); conf.set("complete-random-str", random); conf.set("main-dataset-id", datasetId.get(shortDataset.get(0))); conf.set("remove-not-significant", String.valueOf(removeNotSignificant)); if (noRelationship.length() > 0) { conf.set("no-relationship", noRelationship.substring(0, noRelationship.length() - 1)); } if (hasScoreThreshold) { conf.set("score-threshold", scoreThreshold); } if (hasStrengthThreshold) { conf.set("strength-threshold", strengthThreshold); } conf.set("mapreduce.tasktracker.map.tasks.maximum", String.valueOf(machineConf.getMaximumTasks())); conf.set("mapreduce.tasktracker.reduce.tasks.maximum", String.valueOf(machineConf.getMaximumTasks())); conf.set("mapreduce.jobtracker.maxtasks.perjob", "-1"); conf.set("mapreduce.reduce.shuffle.parallelcopies", "20"); conf.set("mapreduce.input.fileinputformat.split.minsize", "0"); conf.set("mapreduce.task.io.sort.mb", "200"); conf.set("mapreduce.task.io.sort.factor", "100"); conf.set("mapreduce.task.timeout", "2400000"); if (s3) { machineConf.setMachineConfiguration(conf); conf.set("fs.s3.awsAccessKeyId", awsAccessKeyId); conf.set("fs.s3.awsSecretAccessKey", awsSecretAccessKey); conf.set("bucket", s3bucket); } if (snappyCompression) { conf.set("mapreduce.map.output.compress", "true"); conf.set("mapreduce.map.output.compress.codec", "org.apache.hadoop.io.compress.SnappyCodec"); //conf.set("mapreduce.output.fileoutputformat.compress.codec", "org.apache.hadoop.io.compress.SnappyCodec"); } if (bzip2Compression) { conf.set("mapreduce.map.output.compress", "true"); conf.set("mapreduce.map.output.compress.codec", "org.apache.hadoop.io.compress.BZip2Codec"); //conf.set("mapreduce.output.fileoutputformat.compress.codec", "org.apache.hadoop.io.compress.BZip2Codec"); } Job job = new Job(conf); job.setJobName(jobName); job.setMapOutputKeyClass(PairAttributeWritable.class); job.setMapOutputValueClass(TopologyTimeSeriesWritable.class); job.setOutputKeyClass(Text.class); job.setOutputValueClass(Text.class); job.setMapperClass(CorrelationMapper.class); job.setReducerClass(CorrelationReducer.class); job.setNumReduceTasks(machineConf.getNumberReduces()); job.setInputFormatClass(SequenceFileInputFormat.class); //job.setOutputFormatClass(TextOutputFormat.class); LazyOutputFormat.setOutputFormatClass(job, TextOutputFormat.class); FileInputFormat.setInputDirRecursive(job, true); FileInputFormat.setInputPaths(job, indexInputDirs.substring(0, indexInputDirs.length() - 1)); FileOutputFormat.setOutputPath(job, new Path(relationshipOutputDir)); job.setJarByClass(Relationship.class); long start = System.currentTimeMillis(); job.submit(); job.waitForCompletion(true); System.out.println(jobName + "\t" + (System.currentTimeMillis() - start)); // moving files to right place for (int i = 0; i < firstGroup.size(); i++) { for (int j = 0; j < secondGroup.size(); j++) { if (Integer.parseInt(datasetId.get(firstGroup.get(i))) < Integer .parseInt(datasetId.get(secondGroup.get(j)))) { dataset1 = firstGroup.get(i); dataset2 = secondGroup.get(j); } else { dataset1 = secondGroup.get(j); dataset2 = firstGroup.get(i); } if (dataset1.equals(dataset2)) continue; String from = s3bucket + relationshipsDir + "/tmp/" + dataset1 + "-" + dataset2 + "/"; String to = s3bucket + relationshipsDir + "/" + dataset1 + "-" + dataset2 + "/"; FrameworkUtils.renameFile(from, to, s3conf, s3); } } }
From source file:com.samsung.sjs.Compiler.java
@SuppressWarnings("static-access") public static void main(String[] args) throws IOException, SolverException, InterruptedException { boolean debug = false; boolean use_gc = true; CompilerOptions.Platform p = CompilerOptions.Platform.Native; CompilerOptions opts = null;/* ww w . j a v a 2 s .c om*/ boolean field_opts = false; boolean typecheckonly = false; boolean showconstraints = false; boolean showconstraintsolution = false; String[] decls = null; String[] links = null; String[] objs = null; boolean guest = false; boolean stop_at_c = false; String external_compiler = null; boolean encode_vals = false; boolean x32 = false; boolean validate = true; boolean interop = false; boolean boot_interop = false; boolean oldExpl = false; String explanationStrategy = null; boolean efl = false; Options options = new Options(); options.addOption("debugcompiler", false, "Enable compiler debug spew"); //options.addOption("o", true, "Set compiler output file (must be .c)"); options.addOption(OptionBuilder //.withArgName("o") .withLongOpt("output-file").withDescription("Output file (must be .c)").hasArg().withArgName("file") .create("o")); options.addOption(OptionBuilder.withLongOpt("target") .withDescription("Select target platform: 'native' or 'web'").hasArg().create()); options.addOption(OptionBuilder.withLongOpt("gc") .withDescription("Disable GC: param is 'on' (default) or 'off'").hasArg().create()); options.addOption(OptionBuilder .withDescription("Enable field access optimizations: param is 'true' (default) or 'false'").hasArg() .create("Xfields")); options.addOption(OptionBuilder .withDescription("Compile for encoded values. TEMPORARY. For testing interop codegen").hasArg() .create("XEncodedValues")); options.addOption(OptionBuilder.withLongOpt("typecheck-only") .withDescription("Only typecheck the file, don't compile").create()); options.addOption(OptionBuilder.withLongOpt("show-constraints") .withDescription("Show constraints generated during type inference").create()); options.addOption(OptionBuilder.withLongOpt("show-constraint-solution") .withDescription("Show solution to type inference constraints").create()); options.addOption(OptionBuilder.withLongOpt("extra-decls") .withDescription("Specify extra declaration files, comma-separated").hasArg() .withValueSeparator(',').create()); options.addOption(OptionBuilder.withLongOpt("native-libs") .withDescription("Specify extra linkage files, comma-separated").hasArg().withValueSeparator(',') .create()); Option extraobjs = OptionBuilder.withLongOpt("extra-objs") .withDescription("Specify extra .c/.cpp files, comma-separated").hasArg().withValueSeparator(',') .create(); extraobjs.setArgs(Option.UNLIMITED_VALUES); options.addOption(extraobjs); options.addOption(OptionBuilder.withLongOpt("guest-runtime") .withDescription( "Emit code to be called by another runtime (i.e., main() is written in another language).") .create()); options.addOption(OptionBuilder.withLongOpt("only-c") .withDescription("Generate C code, but do not attempt to compile it").create()); options.addOption(OptionBuilder.withLongOpt("c-compiler") .withDescription("Disable GC: param is 'on' (default) or 'off'").hasArg().create("cc")); options.addOption(OptionBuilder.withLongOpt("runtime-src") .withDescription("Specify path to runtime system source").hasArg().create()); options.addOption(OptionBuilder.withLongOpt("ext-path") .withDescription("Specify path to external dependency dir (GC, etc.)").hasArg().create()); options.addOption(OptionBuilder.withLongOpt("skip-validation") .withDescription("Run the backend without validating the results of type inference").create()); options.addOption(OptionBuilder.withLongOpt("m32").withDescription("Force 32-bit compilation").create()); options.addOption(OptionBuilder.withLongOpt("Xbootinterop") .withDescription("Programs start with global interop dirty flag set (experimental)").create()); options.addOption(OptionBuilder.withLongOpt("Xinterop") .withDescription("Enable (experimental) interoperability backend").create()); options.addOption(OptionBuilder.withDescription("C compiler default optimization level").create("O")); options.addOption(OptionBuilder.withDescription("C compiler optimization level 0").create("O0")); options.addOption(OptionBuilder.withDescription("C compiler optimization level 1").create("O1")); options.addOption(OptionBuilder.withDescription("C compiler optimization level 2").create("O2")); options.addOption(OptionBuilder.withDescription("C compiler optimization level 3").create("O3")); options.addOption( OptionBuilder.withLongOpt("oldExpl").withDescription("Use old error explanations").create()); String explanationStrategyHelp = "default: " + FixingSetFinder.defaultStrategy() + "; other choices: " + FixingSetFinder.strategyNames().stream().filter(s -> !s.equals(FixingSetFinder.defaultStrategy())) .collect(Collectors.joining(", ")); options.addOption(OptionBuilder.withLongOpt("explanation-strategy") .withDescription("Error explanation strategy to use (" + explanationStrategyHelp + ')').hasArg() .create()); options.addOption( OptionBuilder.withLongOpt("efl").withDescription("Set up efl environment in main()").create()); try { CommandLineParser parser = new BasicParser(); CommandLine cmd = parser.parse(options, args); String[] newargs = cmd.getArgs(); if (newargs.length != 1) { throw new ParseException("Invalid number of arguments"); } String sourcefile = newargs[0]; if (!sourcefile.endsWith(".js")) { throw new ParseException("Invalid file extension on input file: " + sourcefile); } String gc = cmd.getOptionValue("gc", "on"); if (gc.equals("on")) { use_gc = true; } else if (gc.equals("off")) { use_gc = false; } else { throw new ParseException("Invalid GC option: " + gc); } String fields = cmd.getOptionValue("Xfields", "true"); if (fields.equals("true")) { field_opts = true; } else if (fields.equals("false")) { field_opts = false; } else { throw new ParseException("Invalid field optimization option: " + fields); } String encoding = cmd.getOptionValue("XEncodedValues", "false"); if (encoding.equals("true")) { encode_vals = true; } else if (encoding.equals("false")) { encode_vals = false; } else { throw new ParseException("Invalid value encoding option: " + encode_vals); } String plat = cmd.getOptionValue("target", "native"); if (plat.equals("native")) { p = CompilerOptions.Platform.Native; } else if (plat.equals("web")) { p = CompilerOptions.Platform.Web; } else { throw new ParseException("Invalid target platform: " + plat); } if (cmd.hasOption("cc")) { external_compiler = cmd.getOptionValue("cc"); } if (cmd.hasOption("skip-validation")) { validate = false; } if (cmd.hasOption("typecheck-only")) { typecheckonly = true; } if (cmd.hasOption("show-constraints")) { showconstraints = true; } if (cmd.hasOption("show-constraint-solution")) { showconstraintsolution = true; } if (cmd.hasOption("debugcompiler")) { debug = true; } if (cmd.hasOption("m32")) { x32 = true; } if (cmd.hasOption("Xinterop")) { interop = true; } if (cmd.hasOption("Xbootinterop")) { boot_interop = true; if (!interop) { System.err.println("WARNING: --Xbootinterop enabled without --Xinterop (no effect)"); } } if (cmd.hasOption("oldExpl")) { oldExpl = true; } if (cmd.hasOption("explanation-strategy")) { explanationStrategy = cmd.getOptionValue("explanation-strategy"); } String output = cmd.getOptionValue("o"); if (output == null) { output = sourcefile.replaceFirst(".js$", ".c"); } else { if (!output.endsWith(".c")) { throw new ParseException("Invalid file extension on output file: " + output); } } String runtime_src = cmd.getOptionValue("runtime-src"); String ext_path = cmd.getOptionValue("ext-path"); if (ext_path == null) { ext_path = new File(".").getCanonicalPath() + "/external"; } if (cmd.hasOption("extra-decls")) { decls = cmd.getOptionValues("extra-decls"); } if (cmd.hasOption("native-libs")) { links = cmd.getOptionValues("native-libs"); } if (cmd.hasOption("extra-objs")) { objs = cmd.getOptionValues("extra-objs"); } if (cmd.hasOption("guest-runtime")) { guest = true; } if (cmd.hasOption("only-c")) { stop_at_c = true; } if (cmd.hasOption("efl")) { efl = true; } int coptlevel = -1; // default optimization if (cmd.hasOption("O3")) { coptlevel = 3; } else if (cmd.hasOption("O2")) { coptlevel = 2; } else if (cmd.hasOption("O1")) { coptlevel = 1; } else if (cmd.hasOption("O0")) { coptlevel = 0; } else if (cmd.hasOption("O")) { coptlevel = -1; } else { coptlevel = 3; } if (!Files.exists(Paths.get(sourcefile))) { System.err.println("File " + sourcefile + " was not found."); throw new FileNotFoundException(sourcefile); } String cwd = new java.io.File(".").getCanonicalPath(); opts = new CompilerOptions(p, sourcefile, debug, output, use_gc, external_compiler == null ? "clang" : external_compiler, external_compiler == null ? "emcc" : external_compiler, cwd + "/a.out", // emcc automatically adds .js new File(".").getCanonicalPath(), true, field_opts, showconstraints, showconstraintsolution, runtime_src, encode_vals, x32, oldExpl, explanationStrategy, efl, coptlevel); if (guest) { opts.setGuestRuntime(); } if (interop) { opts.enableInteropMode(); } if (boot_interop) { opts.startInInteropMode(); } opts.setExternalDeps(ext_path); if (decls != null) { for (String s : decls) { Path fname = FileSystems.getDefault().getPath(s); opts.addDeclarationFile(fname); } } if (links != null) { for (String s : links) { Path fname = FileSystems.getDefault().getPath(s); opts.addLinkageFile(fname); } } if (objs == null) { objs = new String[0]; } } catch (Exception e) { System.err.println(e.getMessage()); e.printStackTrace(); HelpFormatter formatter = new HelpFormatter(); formatter.printHelp("sjsc", options); } if (opts != null) { // This typechecks, and depending on flags, also generates C compile(opts, typecheckonly, validate); // don't worry about type validation on command line for now if (!typecheckonly && !stop_at_c) { int ret = 0; // Kept around for debugging 32-bit... if (p == CompilerOptions.Platform.Native) { if (opts.m32()) { String[] x = new String[2]; x[0] = "-m32"; x[1] = opts.getExternalDeps() + "/gc/x86/lib/libgc.a"; ret = clang_compile(opts, objs, x); } else { ret = clang_compile(opts, objs, new String[0]); } } else { ret = emcc_compile(opts, objs, new String[0]); } // If clang failed, propagate the failure outwards if (ret != 0) { System.exit(ret); } } } }
From source file:hrytsenko.gscripts.AppArgs.java
private static Option createOption(String name, String description, boolean required) { Option option = new Option(name, true, description); option.setArgs(Option.UNLIMITED_VALUES); option.setRequired(required);/*from ww w . j a va 2s. c om*/ return option; }
From source file:com.google.play.developerapi.samples.ApplicationConfig.java
public static ApplicationConfig parseArgs(String[] args) { Options options = new Options(); try {/*from w w w . ja va 2 s . c om*/ CommandLineParser parser = new GnuParser(); Option appId = new Option("appId", "Application id (package name)"); appId.setArgs(1); appId.setRequired(true); options.addOption(appId); Option secrets = new Option("secrets", "Client secrets path"); secrets.setArgs(1); secrets.setRequired(true); options.addOption(secrets); Option account = new Option("account", "Service account email"); account.setArgs(1); account.setRequired(false); options.addOption(account); Option appName = new Option("appName", "Application name"); appName.setArgs(1); appName.setRequired(false); options.addOption(appName); Option apkFilePath = new Option("apkFilePath", "Apk file path"); apkFilePath.setArgs(1); apkFilePath.setRequired(false); options.addOption(apkFilePath); return new ApplicationConfig(parser.parse(options, args)); } catch (ParseException ex) { System.err.println(ex.getMessage()); HelpFormatter formatter = new HelpFormatter(); formatter.printHelp("android-publisher-api", options); return null; } }
From source file:hrytsenko.csv.Args.java
private static Option newOption(String name, String description, boolean required) { Option option = new Option(name, true, description); option.setArgs(UNLIMITED_VALUES); option.setRequired(required);/*www. j ava 2s. c o m*/ return option; }
From source file:edu.wisc.my.portlets.dmp.tools.XmlMenuPublisherRunner.java
/** * Set up the command line options/*from w w w . j ava 2 s. c om*/ */ private static Options setupOptions() { final Options opts = new Options(); final Option xmlSource = new Option(XML_FILE_OPT, true, "The relative or absolute file system location of the menu XML document."); xmlSource.setRequired(true); xmlSource.setArgs(1); xmlSource.setArgName("path"); xmlSource.setLongOpt("menuXmlFile"); opts.addOption(xmlSource); return opts; }
From source file:com.octo.mbo.CopyNotes.java
static CommandLine parseCommandLine(String[] args) throws CommandLineException { Options options = new Options(); Option optSource = new Option("s", "Source file where the comments can be extracted (only pptx format supported)"); optSource.setRequired(true);/*from ww w . ja v a 2 s. com*/ optSource.setArgs(1); optSource.setLongOpt("source"); options.addOption(optSource); Option optTarget = new Option("t", "Target file where the comments are merged (case of pptx format)"); optTarget.setRequired(true); optTarget.setArgs(1); optTarget.setLongOpt("target"); options.addOption(optTarget); HelpFormatter formatter = new HelpFormatter(); final String header = "CopyNotes allows to extract, copy and merge notes of pptx files. \n" + "Notes can be merged with the notes of an existing files \n" + "Notes can be exported to a xml file with a custom format or imported \n" + "from this xml format and merged into an existing pptx document. \n" + "The target file is updated \n"; final String footer = ""; CommandLineParser cliParser = new DefaultParser(); try { return cliParser.parse(options, args); } catch (MissingOptionException mex) { log.error(mex.getMessage()); log.debug("Error parsing command line", mex); formatter.printHelp( "java -jar copypptxnotes-<version>-jar-with-dependencies.jar -s <source> -t <target>", header, options, footer); throw new CommandLineException("Missing option", mex); } catch (ParseException pex) { log.debug("Error parsing the command line. Please use CopyComment --help", pex); formatter.printHelp( "java -jar copypptxnotes-<version>-jar-with-dependencies.jar -s <source> -t <target>", header, options, footer); throw new CommandLineException("Parse Exception", pex); } }
From source file:com.linkedin.helix.mock.storage.MockStorageProcess.java
@SuppressWarnings("static-access") private static Options constructCommandLineOptions() { Option helpOption = OptionBuilder.withLongOpt(help).withDescription("Prints command-line options info") .create();//from ww w . java 2 s . co m Option zkServerOption = OptionBuilder.withLongOpt(zkServer).withDescription("Provide zookeeper address") .create(); zkServerOption.setArgs(1); zkServerOption.setRequired(true); zkServerOption.setArgName("ZookeeperServerAddress(Required)"); Option clusterOption = OptionBuilder.withLongOpt(cluster).withDescription("Provide cluster name").create(); clusterOption.setArgs(1); clusterOption.setRequired(true); clusterOption.setArgName("Cluster name (Required)"); Option hostOption = OptionBuilder.withLongOpt(hostAddress).withDescription("Provide host name").create(); hostOption.setArgs(1); hostOption.setRequired(true); hostOption.setArgName("Host name (Required)"); Option portOption = OptionBuilder.withLongOpt(hostPort).withDescription("Provide host port").create(); portOption.setArgs(1); portOption.setRequired(true); portOption.setArgName("Host port (Required)"); Option relayClusterOption = OptionBuilder.withLongOpt(relayCluster) .withDescription("Provide relay cluster name").create(); relayClusterOption.setArgs(1); relayClusterOption.setRequired(true); relayClusterOption.setArgName("Relay cluster name (Required)"); Options options = new Options(); options.addOption(helpOption); options.addOption(zkServerOption); options.addOption(clusterOption); options.addOption(hostOption); options.addOption(portOption); options.addOption(relayClusterOption); return options; }
From source file:net.skyebook.zerocollada.ZeroCollada.java
public static void optionsSetup() { options = new Options(); Option help = new Option(ZCOpts.help, "Print this help menu"); Option transform = new Option(ZCOpts.transform, "Perform a transform. Defaults to closet-to-origin anchor without consideration for the Y-axis"); Option includeX = new Option(ZCOpts.includeX, "Include the X-Axis in this transform calculation"); Option includeY = new Option(ZCOpts.includeY, "Include the Y-Axis in this transform calculation"); Option includeZ = new Option(ZCOpts.includeZ, "Include the Z-Axis in this transform calculation"); Option anchorCenter = new Option(ZCOpts.anchorCenter, "NOT IMPLEMENTED YET -- Anchors the transformation to the middle of the *range* of coordinates (not the average)"); Option translate = new Option(ZCOpts.translate, true, "Change translations"); translate.setArgName("translation type"); translate.setArgs(2); options.addOption(help);/* w w w . j av a2s . c om*/ options.addOption(transform); options.addOption(includeX); options.addOption(includeY); options.addOption(includeZ); options.addOption(anchorCenter); options.addOption(translate); }
From source file:com.rabbitmq.examples.PerfTest.java
private static Options getOptions() { Options options = new Options(); options.addOption(new Option("?", "help", false, "show usage")); options.addOption(new Option("h", "uri", true, "connection URI")); options.addOption(new Option("t", "type", true, "exchange type")); options.addOption(new Option("e", "exchange", true, "exchange name")); options.addOption(new Option("u", "queue", true, "queue name")); options.addOption(new Option("k", "routingKey", true, "routing key")); options.addOption(new Option("K", "randomRoutingKey", false, "use random routing key per message")); options.addOption(new Option("i", "interval", true, "sampling interval in seconds")); options.addOption(new Option("r", "rate", true, "producer rate limit")); options.addOption(new Option("R", "consumerRate", true, "consumer rate limit")); options.addOption(new Option("x", "producers", true, "producer count")); options.addOption(new Option("y", "consumers", true, "consumer count")); options.addOption(new Option("m", "ptxsize", true, "producer tx size")); options.addOption(new Option("n", "ctxsize", true, "consumer tx size")); options.addOption(new Option("c", "confirm", true, "max unconfirmed publishes")); options.addOption(new Option("a", "autoack", false, "auto ack")); options.addOption(new Option("A", "multiAckEvery", true, "multi ack every")); options.addOption(new Option("q", "qos", true, "consumer prefetch count")); options.addOption(new Option("Q", "globalQos", true, "channel prefetch count")); options.addOption(new Option("s", "size", true, "message size in bytes")); options.addOption(new Option("z", "time", true, "run duration in seconds (unlimited by default)")); options.addOption(new Option("C", "pmessages", true, "producer message count")); options.addOption(new Option("D", "cmessages", true, "consumer message count")); Option flag = new Option("f", "flag", true, "message flag"); flag.setArgs(Option.UNLIMITED_VALUES); options.addOption(flag);/*w ww .java2s .co m*/ options.addOption(new Option("M", "framemax", true, "frame max")); options.addOption(new Option("b", "heartbeat", true, "heartbeat interval")); options.addOption(new Option("p", "predeclared", false, "allow use of predeclared objects")); return options; }