List of usage examples for org.apache.commons.cli Option setRequired
public void setRequired(boolean required)
From source file:com.linkedin.helix.tools.ClusterSetup.java
@SuppressWarnings("static-access") private static Options constructCommandLineOptions() { Option helpOption = OptionBuilder.withLongOpt(help).withDescription("Prints command-line options info") .create();/* w w w .ja v a2 s . c o m*/ Option zkServerOption = OptionBuilder.withLongOpt(zkServerAddress) .withDescription("Provide zookeeper address").create(); zkServerOption.setArgs(1); zkServerOption.setRequired(true); zkServerOption.setArgName("ZookeeperServerAddress(Required)"); Option listClustersOption = OptionBuilder.withLongOpt(listClusters) .withDescription("List existing clusters").create(); listClustersOption.setArgs(0); listClustersOption.setRequired(false); Option listResourceOption = OptionBuilder.withLongOpt(listResources) .withDescription("List resources hosted in a cluster").create(); listResourceOption.setArgs(1); listResourceOption.setRequired(false); listResourceOption.setArgName("clusterName"); Option listInstancesOption = OptionBuilder.withLongOpt(listInstances) .withDescription("List Instances in a cluster").create(); listInstancesOption.setArgs(1); listInstancesOption.setRequired(false); listInstancesOption.setArgName("clusterName"); Option addClusterOption = OptionBuilder.withLongOpt(addCluster).withDescription("Add a new cluster") .create(); addClusterOption.setArgs(1); addClusterOption.setRequired(false); addClusterOption.setArgName("clusterName"); Option activateClusterOption = OptionBuilder.withLongOpt(activateCluster) .withDescription("Enable/disable a cluster in distributed controller mode").create(); activateClusterOption.setArgs(3); activateClusterOption.setRequired(false); activateClusterOption.setArgName("clusterName grandCluster true/false"); Option deleteClusterOption = OptionBuilder.withLongOpt(dropCluster).withDescription("Delete a cluster") .create(); deleteClusterOption.setArgs(1); deleteClusterOption.setRequired(false); deleteClusterOption.setArgName("clusterName"); Option addInstanceOption = OptionBuilder.withLongOpt(addInstance) .withDescription("Add a new Instance to a cluster").create(); addInstanceOption.setArgs(2); addInstanceOption.setRequired(false); addInstanceOption.setArgName("clusterName InstanceAddress(host:port)"); Option addResourceOption = OptionBuilder.withLongOpt(addResource) .withDescription("Add a resource to a cluster").create(); addResourceOption.setArgs(4); addResourceOption.setRequired(false); addResourceOption.setArgName("clusterName resourceName partitionNum stateModelRef <-mode modeValue>"); Option expandResourceOption = OptionBuilder.withLongOpt(expandResource) .withDescription("Expand resource to additional nodes").create(); expandResourceOption.setArgs(2); expandResourceOption.setRequired(false); expandResourceOption.setArgName("clusterName resourceName"); Option expandClusterOption = OptionBuilder.withLongOpt(expandCluster) .withDescription("Expand a cluster and all the resources").create(); expandClusterOption.setArgs(1); expandClusterOption.setRequired(false); expandClusterOption.setArgName("clusterName"); Option resourceModeOption = OptionBuilder.withLongOpt(mode) .withDescription("Specify resource mode, used with addResourceGroup command").create(); resourceModeOption.setArgs(1); resourceModeOption.setRequired(false); resourceModeOption.setArgName("IdealState mode"); Option resourceBucketSizeOption = OptionBuilder.withLongOpt(bucketSize) .withDescription("Specify size of a bucket, used with addResourceGroup command").create(); resourceBucketSizeOption.setArgs(1); resourceBucketSizeOption.setRequired(false); resourceBucketSizeOption.setArgName("Size of a bucket for a resource"); Option resourceKeyOption = OptionBuilder.withLongOpt(resourceKeyPrefix) .withDescription("Specify resource key prefix, used with rebalance command").create(); resourceKeyOption.setArgs(1); resourceKeyOption.setRequired(false); resourceKeyOption.setArgName("Resource key prefix"); Option addStateModelDefOption = OptionBuilder.withLongOpt(addStateModelDef) .withDescription("Add a State model to a cluster").create(); addStateModelDefOption.setArgs(2); addStateModelDefOption.setRequired(false); addStateModelDefOption.setArgName("clusterName <filename>"); Option addIdealStateOption = OptionBuilder.withLongOpt(addIdealState) .withDescription("Add a State model to a cluster").create(); addIdealStateOption.setArgs(3); addIdealStateOption.setRequired(false); addIdealStateOption.setArgName("clusterName resourceName <filename>"); Option dropInstanceOption = OptionBuilder.withLongOpt(dropInstance) .withDescription("Drop an existing Instance from a cluster").create(); dropInstanceOption.setArgs(2); dropInstanceOption.setRequired(false); dropInstanceOption.setArgName("clusterName InstanceAddress(host:port)"); Option swapInstanceOption = OptionBuilder.withLongOpt(swapInstance) .withDescription("Swap an old instance from a cluster with a new instance").create(); swapInstanceOption.setArgs(3); swapInstanceOption.setRequired(false); swapInstanceOption.setArgName("clusterName oldInstance newInstance"); Option dropResourceOption = OptionBuilder.withLongOpt(dropResource) .withDescription("Drop an existing resource from a cluster").create(); dropResourceOption.setArgs(2); dropResourceOption.setRequired(false); dropResourceOption.setArgName("clusterName resourceName"); Option rebalanceOption = OptionBuilder.withLongOpt(rebalance) .withDescription("Rebalance a resource in a cluster").create(); rebalanceOption.setArgs(3); rebalanceOption.setRequired(false); rebalanceOption.setArgName("clusterName resourceName replicas"); Option instanceInfoOption = OptionBuilder.withLongOpt(listInstanceInfo) .withDescription("Query info of a Instance in a cluster").create(); instanceInfoOption.setArgs(2); instanceInfoOption.setRequired(false); instanceInfoOption.setArgName("clusterName InstanceName"); Option clusterInfoOption = OptionBuilder.withLongOpt(listClusterInfo) .withDescription("Query info of a cluster").create(); clusterInfoOption.setArgs(1); clusterInfoOption.setRequired(false); clusterInfoOption.setArgName("clusterName"); Option resourceInfoOption = OptionBuilder.withLongOpt(listResourceInfo) .withDescription("Query info of a resource").create(); resourceInfoOption.setArgs(2); resourceInfoOption.setRequired(false); resourceInfoOption.setArgName("clusterName resourceName"); Option addResourcePropertyOption = OptionBuilder.withLongOpt(addResourceProperty) .withDescription("Add a resource property").create(); addResourcePropertyOption.setArgs(4); addResourcePropertyOption.setRequired(false); addResourcePropertyOption.setArgName("clusterName resourceName propertyName propertyValue"); Option removeResourcePropertyOption = OptionBuilder.withLongOpt(removeResourceProperty) .withDescription("Remove a resource property").create(); removeResourcePropertyOption.setArgs(3); removeResourcePropertyOption.setRequired(false); removeResourcePropertyOption.setArgName("clusterName resourceName propertyName"); Option partitionInfoOption = OptionBuilder.withLongOpt(listPartitionInfo) .withDescription("Query info of a partition").create(); partitionInfoOption.setArgs(3); partitionInfoOption.setRequired(false); partitionInfoOption.setArgName("clusterName resourceName partitionName"); Option enableInstanceOption = OptionBuilder.withLongOpt(enableInstance) .withDescription("Enable/disable a Instance").create(); enableInstanceOption.setArgs(3); enableInstanceOption.setRequired(false); enableInstanceOption.setArgName("clusterName InstanceName true/false"); Option enablePartitionOption = OptionBuilder.hasArgs().withLongOpt(enablePartition) .withDescription("Enable/disable partitions").create(); enablePartitionOption.setRequired(false); enablePartitionOption.setArgName("true/false clusterName instanceName resourceName partitionName1..."); Option enableClusterOption = OptionBuilder.withLongOpt(enableCluster) .withDescription("pause/resume the controller of a cluster").create(); enableClusterOption.setArgs(2); enableClusterOption.setRequired(false); enableClusterOption.setArgName("clusterName true/false"); Option resetPartitionOption = OptionBuilder.withLongOpt(resetPartition) .withDescription("Reset a partition in error state").create(); resetPartitionOption.setArgs(4); resetPartitionOption.setRequired(false); resetPartitionOption.setArgName("clusterName instanceName resourceName partitionName"); Option resetInstanceOption = OptionBuilder.withLongOpt(resetInstance) .withDescription("Reset all partitions in error state for an instance").create(); resetInstanceOption.setArgs(2); resetInstanceOption.setRequired(false); resetInstanceOption.setArgName("clusterName instanceName"); Option resetResourceOption = OptionBuilder.withLongOpt(resetResource) .withDescription("Reset all partitions in error state for a resource").create(); resetResourceOption.setArgs(2); resetResourceOption.setRequired(false); resetResourceOption.setArgName("clusterName resourceName"); Option listStateModelsOption = OptionBuilder.withLongOpt(listStateModels) .withDescription("Query info of state models in a cluster").create(); listStateModelsOption.setArgs(1); listStateModelsOption.setRequired(false); listStateModelsOption.setArgName("clusterName"); Option listStateModelOption = OptionBuilder.withLongOpt(listStateModel) .withDescription("Query info of a state model in a cluster").create(); listStateModelOption.setArgs(2); listStateModelOption.setRequired(false); listStateModelOption.setArgName("clusterName stateModelName"); Option addStatOption = OptionBuilder.withLongOpt(addStat).withDescription("Add a persistent stat").create(); addStatOption.setArgs(2); addStatOption.setRequired(false); addStatOption.setArgName("clusterName statName"); Option addAlertOption = OptionBuilder.withLongOpt(addAlert).withDescription("Add an alert").create(); addAlertOption.setArgs(2); addAlertOption.setRequired(false); addAlertOption.setArgName("clusterName alertName"); Option dropStatOption = OptionBuilder.withLongOpt(dropStat).withDescription("Drop a persistent stat") .create(); dropStatOption.setArgs(2); dropStatOption.setRequired(false); dropStatOption.setArgName("clusterName statName"); Option dropAlertOption = OptionBuilder.withLongOpt(dropAlert).withDescription("Drop an alert").create(); dropAlertOption.setArgs(2); dropAlertOption.setRequired(false); dropAlertOption.setArgName("clusterName alertName"); // set/get configs option Option setConfOption = OptionBuilder.withLongOpt(setConfig).withDescription("Set a config").create(); setConfOption.setArgs(2); setConfOption.setRequired(false); setConfOption .setArgName("ConfigScope(e.g. CLUSTER=cluster,RESOURCE=rc,...) KeyValueMap(e.g. k1=v1,k2=v2,...)"); Option getConfOption = OptionBuilder.withLongOpt(getConfig).withDescription("Get a config").create(); getConfOption.setArgs(2); getConfOption.setRequired(false); getConfOption.setArgName("ConfigScope(e.g. CLUSTER=cluster,RESOURCE=rc,...) KeySet(e.g. k1,k2,...)"); OptionGroup group = new OptionGroup(); group.setRequired(true); group.addOption(rebalanceOption); group.addOption(addResourceOption); group.addOption(resourceModeOption); group.addOption(resourceBucketSizeOption); group.addOption(expandResourceOption); group.addOption(expandClusterOption); group.addOption(resourceKeyOption); group.addOption(addClusterOption); group.addOption(activateClusterOption); group.addOption(deleteClusterOption); group.addOption(addInstanceOption); group.addOption(listInstancesOption); group.addOption(listResourceOption); group.addOption(listClustersOption); group.addOption(addIdealStateOption); group.addOption(rebalanceOption); group.addOption(dropInstanceOption); group.addOption(swapInstanceOption); group.addOption(dropResourceOption); group.addOption(instanceInfoOption); group.addOption(clusterInfoOption); group.addOption(resourceInfoOption); group.addOption(partitionInfoOption); group.addOption(enableInstanceOption); group.addOption(enablePartitionOption); group.addOption(enableClusterOption); group.addOption(resetPartitionOption); group.addOption(resetInstanceOption); group.addOption(resetResourceOption); group.addOption(addStateModelDefOption); group.addOption(listStateModelsOption); group.addOption(listStateModelOption); group.addOption(addStatOption); group.addOption(addAlertOption); group.addOption(dropStatOption); group.addOption(dropAlertOption); group.addOption(setConfOption); group.addOption(getConfOption); group.addOption(addResourcePropertyOption); group.addOption(removeResourcePropertyOption); Options options = new Options(); options.addOption(helpOption); options.addOption(zkServerOption); options.addOptionGroup(group); return options; }
From source file:eu.scape_project.tool.toolwrapper.toolwrapper_bash_debian_generator.DebianBashWrapperGenerator.java
/** * Public empty constructor (adds a bunch of command-line options and sets * instance variables values to null)//ww w . ja va 2s . c om */ public DebianBashWrapperGenerator() { super(); Options options = super.getOptions(); Option opt = new Option("e", "email", true, "maintainer e-mail for Debian package generation"); opt.setRequired(true); options.addOption(opt); opt = new Option("a", "aggregate", false, "aggregates all artifacts in a single Debian package (use it with -d)"); opt.setRequired(false); options.addOption(opt); opt = new Option("d", "debName", true, "name of the Debian package (use it with -a)"); opt.setRequired(false); options.addOption(opt); opt = new Option("i", "inDir", true, "directory where to input artifacts are"); opt.setRequired(true); options.addOption(opt); opt = new Option("ar", "architecture", true, "define Debian package architecture (default: all; other usual values: i386, amd64)"); opt.setRequired(false); options.addOption(opt); opt = new Option("li", "lintianOverride", true, "define file with lintian override instructions"); opt.setRequired(false); options.addOption(opt); // maintainer scripts options opt = new Option("pi", "preinst", true, "define preinst maintainer script file location"); opt.setRequired(false); options.addOption(opt); opt = new Option("prm", "prerm", true, "define prerm maintainer script file location"); opt.setRequired(false); options.addOption(opt); opt = new Option("poi", "postinst", true, "define postinst maintainer script file location"); opt.setRequired(false); options.addOption(opt); opt = new Option("porm", "postrm", true, "define postrm maintainer script file location"); opt.setRequired(false); options.addOption(opt); opt = new Option("ch", "changelog", true, "location of the changelog to be included"); opt.setRequired(true); options.addOption(opt); opt = new Option(CMD_OPTIONS_DESCRIPTION_SHORT, "description", true, "description to be added to the Debian package (use it with -a and -d)"); opt.setRequired(false); options.addOption(opt); tool = null; operation = null; wrapperName = null; maintainerEmail = null; inputDir = null; debianTemplates = null; changelog = null; lintianOverride = null; architecture = "all"; description = ""; outputDirectory = null; aggregate = true; tempDebianBaseDir = null; tempDebianDir = null; tempDebianInnerDir = null; debianTemplates = null; pi = null; prm = null; poi = null; porm = null; }
From source file:com.selventa.whistle.cli.Rcr.java
/** * Retrieve the {@link Options} applicable to Rcr. * * @return/*from ww w.j av a2 s . c om*/ */ protected Options getCommandLineOptions() { Options ret = new Options(); Option o = new Option(KAM_SHORT_OPT, KAM_LONG_OPT, true, "KAM name. Must be present in the local KAM catalog."); o.setRequired(true); ret.addOption(o); o = new Option(DATA_SHORT_OPT, DATA_LONG_OPT, true, "Data set input file. The file should be in valid IdAMP format. " + "If more than one comparison is represented you will be prompted to choose one."); o.setRequired(true); ret.addOption(o); o = new Option(RUN_NAME_SHORT_OPT, RUN_NAME_LONG_OPT, true, "Name of the whistle run used as a file prefix."); o.setRequired(true); ret.addOption(o); o = new Option(NS_URL_SHORT_OPT, NS_URL_LONG_OPT, true, "Resource location URL of the namespace containing all values of the data set input file."); o.setRequired(true); ret.addOption(o); ret.addOption(new Option(ANLST_SHORT_OPT, ANLST_LONG_OPT, false, "Use analyst selection to filter Measurements to state changes.")); ret.addOption(new Option(FOLD_CHANGE_SHORT_OPT, FOLD_CHANGE_LONG_OPT, true, "Fold change cutoff to apply to Measurements for state change generation. Applicable only if not using analyst selection.")); ret.addOption(new Option(PVAL_SHORT_OPT, PVAL_LONG_OPT, true, "P-value cutoff to apply to Measurements for state change generation. Applicable only if not using analyst selection.")); ret.addOption(new Option(ABUN_SHORT_OPT, ABUN_LONG_OPT, true, "Abundance cutoff to apply to Measurements for state change generation. Applicable only if not using analyst selection.")); ret.addOption(new Option(POP_SIZE_SHORT_OPT, POP_SIZE_LONG_OPT, true, "Population size. The default is to calculate population based on the data set measurements that exist in the KAM.")); ret.addOption(new Option(DETAIL_LONG_OPT, false, "Output a mapping and mechanism detail file that shows additional information")); ret.addOption(new Option(SPECIES_TAXID_SHORT_OPT, SPECIES_TAXID_LONG_OPT, true, "The species taxonomy id used to collapse orthologous nodes.")); return ret; }
From source file:edu.cornell.med.icb.geo.tools.MicroarrayTrainEvaluate.java
private void proccess(final String[] args) { // create the Options final Options options = new Options(); // help/* w w w . j a v a 2 s . c om*/ options.addOption("h", "help", false, "print this message. When -r is used with a non zero integer n, " + "a set of n random gene lists is evaluated for each line of the task list. The evaluation statistics " + "reported is the number of random gene lists that obtained the same or better leave-one-out performance than " + "the gene list from the task list. Accuracy is used to evaluate performance for random trials. "); // input file name final Option inputOption = new Option("i", "input", true, "specify a GEO or RES data set file (GDS file or whitehead RES format)"); inputOption.setArgName("file"); inputOption.setRequired(true); options.addOption(inputOption); // output file name final Option outputOption = new Option("o", "output", true, "specify the destination file where statistics will be written"); outputOption.setArgName("file"); outputOption.setRequired(true); options.addOption(outputOption); // task list file name final Option tasksFilenameOption = new Option("t", "task-list", true, "specify the file with the list of tasks to perform. This file is tab separated"); tasksFilenameOption.setArgName("file"); tasksFilenameOption.setRequired(true); options.addOption(tasksFilenameOption); // condition identifiers file name final Option conditionsIdsFilenameOption = new Option("c", "conditions", true, "specify the file with the mapping condition-name column-identifier (tab separated, on mapping per line)."); conditionsIdsFilenameOption.setArgName("file"); conditionsIdsFilenameOption.setRequired(true); options.addOption(conditionsIdsFilenameOption); // gene lists file name final Option geneListsFilenameOption = new Option("g", "gene-list", true, "specify the file with the gene lists (one per line)."); geneListsFilenameOption.setArgName("file"); geneListsFilenameOption.setRequired(true); options.addOption(geneListsFilenameOption); // Geo platform description file name final Option platformDescriptionFilenameOption = new Option("p", "platform", true, "specify the platform description file(s) (GEO GPL file format). Multiple platorm files may be provided " + " if separated by coma (e.g., file1,file2). Each file is read in the order provided."); platformDescriptionFilenameOption.setArgName("file,file"); platformDescriptionFilenameOption.setRequired(true); options.addOption(platformDescriptionFilenameOption); // Number of random runs (picking probesets randomly that are not in the gene list) final Option randomRunCountOption = new Option("r", "random-run-count", true, "Number of random runs to execute for each random gene list."); randomRunCountOption.setArgName("number"); randomRunCountOption.setRequired(false); options.addOption(randomRunCountOption); // Number of probeset to randomly select for each random run final Option batchSizeRandomRun = new Option("b", "batch-size-random-run", true, "Number of probeset to randomly select for each random run. Default is " + DEFAULT_RANDOM_BATCH_SIZE + "."); batchSizeRandomRun.setArgName("number"); batchSizeRandomRun.setRequired(false); options.addOption(batchSizeRandomRun); // Number of shuffle runs (shuffling the training label). final Option shuffleRunCountOption = new Option("u", "shuffle-run-count", true, "Number of shuffle runs (label permutations) to execute for each training set."); shuffleRunCountOption.setArgName("number"); shuffleRunCountOption.setRequired(false); options.addOption(shuffleRunCountOption); // Minimal signal value for signal floor adjustment. final Option floorSignalValueOption = new Option("f", "floor", true, "Specify a floor value for the signal. If a signal is lower than the floor, it is set to the floor."); floorSignalValueOption.setArgName("number"); floorSignalValueOption.setRequired(false); options.addOption(floorSignalValueOption); // distinguish between one channel array and two channel array final Option channelOption = new Option("a", "two-channel-array", false, "Indicate that the data is for a two channel array. This flag affects how the floor value is interpreted." + "For two channel arrays, values on the array are set to 1.0 if (Math.abs(oldValue-1.0)+1)<=floorValue, " + "whereas for one channel array the condition becomes: oldValue<=floorValue."); channelOption.setRequired(false); options.addOption(channelOption); // Minimal signal value for signal floor adjustment. final Option svmLightOption = new Option("l", "light", false, "Choose svmLight. (default libSVM)."); svmLightOption.setRequired(false); options.addOption(svmLightOption); // Number of random runs final Option seedOption = new Option("s", "seed", true, "Seed for the number generator."); seedOption.setArgName("number"); seedOption.setRequired(false); // Timeout for stopping svmlight in seconds if the process does not complete. final Option timeoutOption = new Option("x", "timeout", true, "Timeout for svmLight training, in seconds (default 3600 seconds/1h)."); timeoutOption.setArgName("number"); timeoutOption.setRequired(false); options.addOption(timeoutOption); final Option clusterFilename = new Option("e", "clusters", true, "Name of file that describes clusters of genes. "); clusterFilename.setArgName("filename"); clusterFilename.setRequired(false); options.addOption(clusterFilename); // parse the command line arguments CommandLine line = null; final double defaultLabelValue = 0; try { // create the command line parser final CommandLineParser parser = new BasicParser(); line = parser.parse(options, args, true); } catch (ParseException e) { System.err.println(e.getMessage()); usage(options); System.exit(1); } // print help and exit if (line.hasOption("h")) { usage(options); System.exit(0); } try { int randomRunCount = 0; final String randomCount = line.getOptionValue("r"); if (randomCount != null) { randomRunCount = Integer.parseInt(randomCount); } if (line.hasOption("l")) { this.svmLight = true; } System.out.println("Using " + (svmLight ? "svmLight" : "libSVM")); final String batchSize = line.getOptionValue("b"); if (batchSize != null) { this.randomBatchSize = Integer.parseInt(batchSize); } else { this.randomBatchSize = DEFAULT_RANDOM_BATCH_SIZE; } System.out.println("Will do " + randomRunCount + " random runs with batch-size=" + randomBatchSize); if (line.hasOption("a")) { this.oneChannelArray = false; } else { this.oneChannelArray = true; } final String floorOptionValue = line.getOptionValue("f"); if (floorOptionValue != null) { adjustSignalToFloorValue = true; if (oneChannelArray) { this.signalFloorValue = DEFAULT_SIGNAL_FLOOR_VALUE_SINGLE_CHANNEL; this.signalFloorValue = Integer.parseInt(floorOptionValue); } else { this.signalFloorValue = DEFAULT_SIGNAL_FLOOR_VALUE_TWO_CHANNELS; this.signalFloorValue = Float.parseFloat(floorOptionValue); } System.out.println("Clipping signal at floor value: " + signalFloorValue); System.out.println("This chip has " + (oneChannelArray ? " one channel." : "two channels.")); } int seed = (int) new Date().getTime(); if (line.getOptionValue("s") != null) { seed = Integer.parseInt(line.getOptionValue("s")); } randomGenerator = new MersenneTwister(seed); int timeout = 60 * 60; // in seconds. // 1 hour if (line.getOptionValue("x") != null) { if (!svmLight) { System.out.println("Error: --timeout option can only be used with --light option."); System.exit(1); } timeout = Integer.parseInt(line.getOptionValue("x")); System.out.println("Timeout set to " + timeout + " second(s)."); } this.timeout = timeout * 1000; final ClassificationTask[] tasks = readTasksAndConditions(line.getOptionValue("t"), line.getOptionValue("c")); final GeneList[] geneList = readGeneList(line.getOptionValue("p"), line.getOptionValue("g")); formatter = new DecimalFormat(); formatter.setMaximumFractionDigits(2); final String uOption = line.getOptionValue("u"); if (uOption == null) { countShuffleLabelTests = 0; } else { countShuffleLabelTests = Integer.parseInt(uOption); } System.out.println("Will do " + countShuffleLabelTests + " shuffling runs"); final File outputFile = new File(line.getOptionValue("o")); final boolean outputFilePreexist = outputFile.exists(); final PrintWriter statWriter = new PrintWriter(new FileWriter(outputFile, true)); // append stats to output. if (!outputFilePreexist) { ClassificationResults.writeHeader(statWriter, shuffleLabelTest); } convert(line.getOptionValue("i"), statWriter, tasks, geneList, randomRunCount); statWriter.close(); System.exit(0); } catch (Exception e) { System.out.println(e); e.printStackTrace(); System.exit(10); } }
From source file:com.trsst.Command.java
@SuppressWarnings("static-access") private void buildOptions(String[] argv, PrintStream out, InputStream in) { // NOTE: OptionsBuilder is NOT thread-safe // which was causing us random failures. Option o; portOptions = new Options(); o = new Option(null, "Specify port"); o.setRequired(false); o.setArgs(1);/*from www . j a v a 2 s . c o m*/ o.setLongOpt("port"); portOptions.addOption(o); o = new Option(null, "Expose client API"); o.setRequired(false); o.setArgs(0); o.setLongOpt("api"); portOptions.addOption(o); o = new Option(null, "Launch embedded GUI"); o.setRequired(false); o.setArgs(0); o.setLongOpt("gui"); portOptions.addOption(o); o = new Option(null, "Turn off SSL"); o.setRequired(false); o.setArgs(0); o.setLongOpt("clear"); portOptions.addOption(o); o = new Option(null, "Use TOR (experimental)"); o.setRequired(false); o.setArgs(0); o.setLongOpt("tor"); portOptions.addOption(o); pullOptions = new Options(); o = new Option("h", "Set host server for this operation"); o.setRequired(false); o.setArgs(1); o.setArgName("url"); o.setLongOpt("host"); pullOptions.addOption(o); o = new Option("d", "Decrypt entries as specified recipient id"); o.setRequired(false); o.setArgs(1); o.setArgName("id"); o.setLongOpt("decrypt"); pullOptions.addOption(o); postOptions = new Options(); o = new Option("a", "Attach the specified file, or - for std input"); o.setRequired(false); o.setOptionalArg(true); o.setArgName("file"); o.setLongOpt("attach"); postOptions.addOption(o); o = new Option("b", "Set base URL for this feed"); o.setRequired(false); o.setArgs(1); o.setArgName("url"); o.setLongOpt("base"); postOptions.addOption(o); o = new Option("p", "Specify passphrase on the command line"); o.setRequired(false); o.setArgs(1); o.setArgName("text"); o.setLongOpt("pass"); postOptions.addOption(o); o = new Option("s", "Specify status update on command line"); o.setRequired(false); o.setArgs(1); o.setArgName("text"); o.setLongOpt("status"); postOptions.addOption(o); o = new Option("u", "Attach the specified url to the new entry"); o.setRequired(false); o.setArgs(1); o.setArgName("url"); o.setLongOpt("url"); postOptions.addOption(o); o = new Option("v", "Specify an activitystreams verb for this entry"); o.setRequired(false); o.setArgs(1); o.setArgName("verb"); o.setLongOpt("verb"); postOptions.addOption(o); o = new Option("r", "Add a mention"); o.setRequired(false); o.setArgs(1); o.setArgName("id"); o.setLongOpt("mention"); postOptions.addOption(o); o = new Option("g", "Add a tag"); o.setRequired(false); o.setArgs(1); o.setArgName("text"); o.setLongOpt("tag"); postOptions.addOption(o); o = new Option("c", "Specify entry content on command line"); o.setRequired(false); o.setArgs(1); o.setArgName("text"); o.setLongOpt("content"); postOptions.addOption(o); o = new Option("t", "Set this feed's title"); o.setRequired(false); o.setArgs(1); o.setArgName("text"); o.setLongOpt("title"); postOptions.addOption(o); o = new Option(null, "Set this feed's subtitle"); o.setRequired(false); o.setArgs(1); o.setArgName("text"); o.setLongOpt("subtitle"); postOptions.addOption(o); o = new Option("n", "Set this feed's author name"); o.setRequired(false); o.setArgs(1); o.setArgName("text"); o.setLongOpt("name"); postOptions.addOption(o); o = new Option(null, "Set this feed's author uri"); o.setRequired(false); o.setArgs(1); o.setArgName("uri"); o.setLongOpt("uri"); postOptions.addOption(o); o = new Option("e", "Encrypt entry for specified public key"); o.setRequired(false); o.setArgs(1); o.setArgName("pubkey"); o.setLongOpt("encrypt"); postOptions.addOption(o); o = new Option("m", "Set this feed's author email"); o.setRequired(false); o.setArgs(1); o.setArgName("email"); o.setLongOpt("email"); postOptions.addOption(o); o = new Option("i", "Set as this feed's icon or specify url"); o.setRequired(false); o.setArgs(1); o.setArgName("url"); o.setLongOpt("icon"); postOptions.addOption(o); o = new Option("l", "Set as this feed's logo or specify url"); o.setRequired(false); o.setArgs(1); o.setArgName("url"); o.setLongOpt("logo"); postOptions.addOption(o); o = new Option(null, "Generate feed id with specified prefix"); o.setRequired(false); o.setArgs(1); o.setArgName("prefix"); o.setLongOpt("vanity"); postOptions.addOption(o); o = new Option(null, "Require SSL certs"); o.setRequired(false); o.setArgs(0); o.setLongOpt("strict"); postOptions.addOption(o); // merge options parameters mergedOptions = new Options(); for (Object obj : pullOptions.getOptions()) { mergedOptions.addOption((Option) obj); } for (Object obj : postOptions.getOptions()) { mergedOptions.addOption((Option) obj); } for (Object obj : portOptions.getOptions()) { mergedOptions.addOption((Option) obj); } helpOption = OptionBuilder.isRequired(false).withLongOpt("help").withDescription("Display these options") .create('?'); mergedOptions.addOption(helpOption); }
From source file:com.gele.tools.wow.wdbearmanager.WDBearManager.java
public void parseCommandLine(String[] parArgs) { // parse the command line this.options = new Options(); // flags// w w w. j a v a 2s. c o m Option optTmp = new Option(this.PARAM_GUI, false, "use GUI"); optTmp.setRequired(false); this.options.addOption(optTmp); optTmp = new Option(this.PARAM_PATCH_UTF8, false, "write UTF-8 text when patching SCP files (not recommended for WadEmu)"); optTmp.setRequired(false); this.options.addOption(optTmp); optTmp = new Option(this.PARAM_UPDATE, false, "update existing database entries"); optTmp.setRequired(false); this.options.addOption(optTmp); optTmp = new Option(this.PARAM_WRITE_SQL, false, "write to SQL database, needs '" + this.PARAM_WDBFILE + "'"); optTmp.setRequired(false); this.options.addOption(optTmp); optTmp = new Option(this.PARAM_VERBOSE, false, "verbose mode, print info"); optTmp.setRequired(false); this.options.addOption(optTmp); // key-value optTmp = new Option(this.PARAM_DBCONFIG, true, "specify alternative database properties; default: 'wdbearmanager_sql.properties'"); optTmp.setRequired(false); this.options.addOption(optTmp); optTmp = new Option(this.PARAM_WDBFILE, true, "name of wdb file to import"); optTmp.setRequired(false); this.options.addOption(optTmp); optTmp = new Option(this.PARAM_LOCALE, true, "locale to be used(eg: enUS, deDE, etc) " + "This is needed if you want to patch SCP files or export WDBTEXT"); optTmp.setRequired(false); this.options.addOption(optTmp); optTmp = new Option(this.PARAM_CSVFOLDER, true, "output CSV to this folder, needs '" + this.PARAM_WDBFILE + "'"); optTmp.setRequired(false); this.options.addOption(optTmp); optTmp = new Option(this.PARAM_TXTFOLDER, true, "output TXT to this folder, needs '" + this.PARAM_WDBFILE + "'"); optTmp.setRequired(false); this.options.addOption(optTmp); optTmp = new Option(this.SCP_NAME, true, "name of the SCP file to patch, use this in conjunction with '" + WDBearManager.PATCH_SCP + "'"); optTmp.setRequired(false); this.options.addOption(optTmp); optTmp = new Option(WDBearManager.PATCH_SCP, true, "type of the SCP file to patch, eg 'quests', 'items', 'creatures', or 'pages'"); optTmp.setRequired(false); this.options.addOption(optTmp); optTmp = new Option(this.PARAM_SCRIPT, true, "specify a Jython script, receives 'wdbmgrapi' variable which contains WDBearManager_API instance"); optTmp.setRequired(false); this.options.addOption(optTmp); Option property = OptionBuilder.withArgName("parameter=value").hasArg().withValueSeparator('^') .withDescription("set value for Jython script").create(this.PARAM_JYTHON); property.setRequired(false); this.options.addOption(property); // // Parse CommandLineParser parser = new GnuParser(); CommandLine cmdLine = null; try { cmdLine = parser.parse(this.options, parArgs); } catch (ParseException ex) { //ex.printStackTrace(); usage(this.options); System.exit(0); } if (cmdLine.hasOption(this.PARAM_JYTHON)) { // initialise the member variable String[] params = cmdLine.getOptionValues(this.PARAM_JYTHON); for (int i = 0; i < params.length; i++) { String[] result = params[i].split("="); if (result.length != 2) { this.myLogger.error("Error in specifying -J parameter '" + params[i] + "': Use param=value"); System.exit(0); } this.paramJython.put(result[0], result[1]); } } // no options if (cmdLine.hasOption(this.PARAM_GUI)) { this.useGUI = true; } if (cmdLine.hasOption(this.PARAM_PATCH_UTF8)) { this.patchUTF8 = true; } if (cmdLine.hasOption(this.PARAM_WRITE_SQL)) { this.writeSQL = true; } if (cmdLine.hasOption(this.PARAM_VERBOSE)) { this.useVerbose = true; } if (cmdLine.hasOption(this.PARAM_UPDATE)) { this.doUpdate = true; } this.paramTXTFolder = cmdLine.getOptionValue(this.PARAM_TXTFOLDER, this.paramTXTFolder); this.paramCSVFolder = cmdLine.getOptionValue(this.PARAM_CSVFOLDER, this.paramCSVFolder); this.paramWdbfile = cmdLine.getOptionValue(this.PARAM_WDBFILE, this.paramWdbfile); this.paramLocale = cmdLine.getOptionValue(this.PARAM_WDBFILE, this.paramLocale); this.paramSCPname = cmdLine.getOptionValue(this.SCP_NAME, this.paramSCPname); this.paramPatchSCP = cmdLine.getOptionValue(WDBearManager.PATCH_SCP, this.paramPatchSCP); this.paramScript = cmdLine.getOptionValue(this.PARAM_SCRIPT, this.paramScript); this.paramDBconfig = cmdLine.getOptionValue(this.PARAM_DBCONFIG, this.paramDBconfig); }
From source file:br.edu.ufcg.lsd.oursim.ui.CLI.java
public static Options prepareOptions() { // Para adicionar uma evento: // 1. Defina uma constante com a identificao da opo // 2. Cria a Option referente // 3. Opcionalmente defina o tipo do argumento, quantidade de parmetros // ou restries // 4. Adicione a Options Options options = new Options(); Option availability = new Option(AVAILABILITY, "availability", true, "Arquivo com a caracterizao da disponibilidade para todos os recursos."); Option dedicatedResources = new Option(DEDICATED_RESOURCES, "dedicated", false, "Indica que os recursos so todos dedicados."); Option syntAvail = new Option(SYNTHETIC_AVAILABILITY, "synthetic_availability", true, "Disponibilidade dos recursos deve ser gerada sinteticamente."); Option syntAvailDur = new Option(SYNTHETIC_AVAILABILITY_DURATION, "synthetic_availability_duration", true, "At que momento gerar eventos de disponibilidade dos recursos."); Option workload = new Option(WORKLOAD, "workload", true, "Arquivo com o workload no format GWA (Grid Workload Archive)."); Option utilization = new Option(UTILIZATION, "utilization", true, "Arquivo em que ser registrada a utilizao da grade."); Option workerEvents = new Option(WORKER_EVENTS, "worker_events", true, "Arquivo em que sero registrados os eventos de disponibilidade."); Option taskEvents = new Option(TASK_EVENTS, "task_events", true, "Arquivo em que ser registrados os eventos de envolvendo tasks."); Option workloadType = new Option(WORKLOAD_TYPE, "workload_type", true, "The type of workload to read the workload file."); Option machinesDescription = new Option(MACHINES_DESCRIPTION, "machinesdescription", true, "Descrio das mquinas presentes em cada peer."); Option speedOption = new Option(NODE_MIPS_RATING, "speed", true, "A velocidade de cada mquina."); Option scheduler = new Option(SCHEDULER, "scheduler", true, "Indica qual scheduler dever ser usado."); Option peersDescription = new Option(PEERS_DESCRIPTION, "peers_description", true, "Arquivo descrevendo os peers."); Option numResByPeer = new Option(NUM_RESOURCES_BY_PEER, "nresources", true, "O nmero de rplicas para cada task."); Option numPeers = new Option(NUM_PEERS, "npeers", true, "O nmero de peers do grid."); Option nofOption = new Option(NOF, "nof", false, "Utiliza a Rede de Favores (NoF)."); Option erwOption = new Option(EXTRACT_REMOTE_WORKLOAD, "extract_remote_workload", true, "Extrai, para cada job, o subconjunto das tasks que rodaram em recursos remotos."); Option output = new Option(OUTPUT, "output", true, "O nome do arquivo em que o output da simulao ser gravado."); Option halt = new Option(HALT_SIMULATION, "halt", true, "O tempo em que a simulao deve parar incondicionalmente."); workload.setRequired(true); peersDescription.setRequired(true);//from w w w .j av a 2 s . c o m output.setRequired(true); workload.setType(File.class); peersDescription.setType(File.class); machinesDescription.setType(File.class); availability.setType(File.class); utilization.setType(File.class); workerEvents.setType(File.class); taskEvents.setType(File.class); output.setType(File.class); erwOption.setType(File.class); numResByPeer.setType(Number.class); numPeers.setType(Number.class); speedOption.setType(Number.class); // syntAvail.setType(Number.class); syntAvailDur.setType(Number.class); syntAvail.setType(String.class); halt.setType(Number.class); scheduler.setArgs(2); availability.setArgs(2); // syntAvail.setArgs(2); OptionGroup availGroup = new OptionGroup(); availGroup.addOption(availability); availGroup.addOption(dedicatedResources); availGroup.addOption(syntAvail); options.addOptionGroup(availGroup); options.addOption(workload); options.addOption(workloadType); options.addOption(machinesDescription); options.addOption(scheduler); options.addOption(syntAvailDur); options.addOption(output); options.addOption(erwOption); options.addOption(numResByPeer); options.addOption(numPeers); options.addOption(peersDescription); options.addOption(speedOption); options.addOption(nofOption); options.addOption(utilization); options.addOption(workerEvents); options.addOption(taskEvents); options.addOption(halt); options.addOption(VERBOSE, "verbose", false, "Informa todos os eventos importantes."); options.addOption(HELP, false, "Comando de ajuda."); options.addOption(USAGE, false, "Instrues de uso."); return options; }
From source file:com.stumbleupon.hbaseadmin.HBaseCompact.java
/** * Returns the command-line options supported. * /*from w ww . java2s . c om*/ * @return the command-line options */ private static Options getOptions() { Options options = new Options(); Option hbaseSite = new Option("c", "hbaseSite", true, "Path to hbase-site.xml"); Option jmxRemotePass = new Option("j", "jmsRemotePassword", true, "Path to jmxremote.password"); Option throttleFactor = new Option("t", "throttleFactor", true, "Throttle factor to limit the compaction queue. The default (1) limits it to num threads / 1"); Option numCycles = new Option("n", "numCycles", true, "Number of iterations to run. The default is 1. Set to 0 to run forever"); Option pauseInterval = new Option("p", "pauseInterval", true, "Time (in milliseconds) to pause between compactions"); Option waitInterval = new Option("w", "waitInterval", true, "Time (in milliseconds) to wait between time (are we there yet?) checks"); Option startTime = new Option("s", "startTime", true, "Time to start compactions. Format is hh:mm"); Option endTime = new Option("e", "endTime", true, "Time to stop compactions. Format is hh:mm"); Option tableNames = new Option("b", "tableNames", true, "Comma-delimited list. Specific table names to check against (default is all)"); Option filesKeep = new Option("f", "filesKeep", true, "Number of storefiles to look for before compacting (default is 5)"); Option jmxPort = new Option("r", "jmxPort", true, "The remote jmx port number"); Option excludeTables = new Option("x", "excludeTables", false, "Treat --tableNames option as a list of tables to exclude from compaction"); Option regionCompactWaitTime = new Option("m", "regionCompactWaitTime", true, "The time in ms to wait before the compaction of the same region. Set to -1 to not wait"); Option maxStoreFileAge = new Option("a", "maxStoreFileAge", true, "Force compaction of a region when its oldest file is older than this value. Default: 0 (disabled)"); hbaseSite.setRequired(true); jmxRemotePass.setRequired(false); throttleFactor.setRequired(false); numCycles.setRequired(false); pauseInterval.setRequired(false); waitInterval.setRequired(false); startTime.setRequired(true); endTime.setRequired(true); tableNames.setRequired(false); filesKeep.setRequired(false); jmxPort.setRequired(true); excludeTables.setRequired(false); regionCompactWaitTime.setRequired(false); maxStoreFileAge.setRequired(false); options.addOption(hbaseSite); options.addOption(jmxRemotePass); options.addOption(throttleFactor); options.addOption(numCycles); options.addOption(pauseInterval); options.addOption(waitInterval); options.addOption(startTime); options.addOption(endTime); options.addOption(tableNames); options.addOption(filesKeep); options.addOption(jmxPort); options.addOption(excludeTables); options.addOption(regionCompactWaitTime); options.addOption(maxStoreFileAge); return options; }
From source file:de.uni_koblenz.jgralab.utilities.rsa2tg.Rsa2Tg.java
/** * Processes all command line parameters and returns a {@link CommandLine} * object, which holds all values included in the given {@link String} * array.//from w w w. j a va2s. c om * * @param args * {@link CommandLine} parameters. * @return {@link CommandLine} object, which holds all necessary values. */ public static CommandLine processCommandLineOptions(String[] args) { // Creates a OptionHandler. String toolString = "java " + Rsa2Tg.class.getName(); String versionString = JGraLab.getInfo(false); // TODO Add an additional help string to the help page. // This String needs to be included into the OptionHandler, but // the functionality is not present. // String additional = // "If no optional output option is selected, a file with the name " // + "\"<InputFileName>.rsa.tg\" will be written." // + "\n\n" // + toolString; OptionHandler oh = new OptionHandler(toolString, versionString); // Several Options are declared. Option validate = new Option(OPTION_FILENAME_VALIDATION, "report", true, "(optional): writes a validation report to the given filename. " + "Free naming, but should look like this: '<filename>.html'"); validate.setRequired(false); validate.setArgName("filename"); oh.addOption(validate); Option export = new Option(OPTION_FILENAME_DOT, "export", true, "(optional): writes a GraphViz DOT file to the given filename. " + "Free naming, but should look like this: '<filename>.dot'"); export.setRequired(false); export.setArgName("filename"); oh.addOption(export); Option schemaGraph = new Option(OPTION_FILENAME_SCHEMA_GRAPH, "schemaGraph", true, "(optional): writes a TG-file of the Schema as graph instance to the given filename. " + "Free naming, but should look like this: '<filename>.tg'"); schemaGraph.setRequired(false); schemaGraph.setArgName("filename"); oh.addOption(schemaGraph); Option input = new Option("i", "input", true, "(required): UML 2.1-XMI exchange model file of the Schema."); input.setRequired(true); input.setArgName("filename"); oh.addOption(input); Option output = new Option(OPTION_FILENAME_SCHEMA, "output", true, "(optional): writes a TG-file of the Schema to the given filename. " + "Free naming, but should look like this: '<filename>.rsa.tg.'"); output.setRequired(false); output.setArgName("filename"); oh.addOption(output); Option fromRole = new Option(OPTION_USE_ROLE_NAME, "useFromRole", false, "(optional): if this flag is set, the name of from roles will be used for creating undefined EdgeClass names."); fromRole.setRequired(false); oh.addOption(fromRole); Option unusedDomains = new Option(OPTION_REMOVE_UNUSED_DOMAINS, "removeUnusedDomains", false, "(optional): if this flag is set, all unused domains be deleted."); unusedDomains.setRequired(false); oh.addOption(unusedDomains); Option removeComments = new Option(OPTION_REMOVE_COMMENTS, "removeComments", false, "(optional): if this flag is set, all comments are removed."); removeComments.setRequired(false); oh.addOption(removeComments); Option emptyPackages = new Option(OPTION_KEEP_EMPTY_PACKAGES, "keepEmptyPackages", false, "(optional): if this flag is set, empty packages will be retained."); emptyPackages.setRequired(false); oh.addOption(emptyPackages); Option navigability = new Option(OPTION_USE_NAVIGABILITY, "useNavigability", false, "(optional): if this flag is set, navigability information will be interpreted as reading direction."); navigability.setRequired(false); oh.addOption(navigability); Option ignoreStereotypes = new Option(OPTION_IGNORE_UNKNOWN_STEREOTYPES, "ignoreUnknownStereotypes", false, "(optional): if this flag is set, unknown stereotypes are ignored."); ignoreStereotypes.setRequired(false); oh.addOption(ignoreStereotypes); // Parses the given command line parameters with all created Option. return oh.parse(args); }
From source file:de.uni_koblenz.jgralab.utilities.rsa.Rsa2Tg.java
/** * Processes all command line parameters and returns a {@link CommandLine} * object, which holds all values included in the given {@link String} * array./* w ww.j a v a2 s. com*/ * * @param args * {@link CommandLine} parameters. * @return {@link CommandLine} object, which holds all necessary values. */ public static CommandLine processCommandLineOptions(String[] args) { // Creates a OptionHandler. String toolString = "java " + Rsa2Tg.class.getName(); String versionString = JGraLab.getInfo(false); // TODO Add an additional help string to the help page. // This String needs to be included into the OptionHandler, but // the functionality is not present. // String additional = // "If no optional output option is selected, a file with the name " // + "\"<InputFileName>.rsa.tg\" will be written." // + "\n\n" // + toolString; OptionHandler oh = new OptionHandler(toolString, versionString); // Several Options are declared. Option validate = new Option(OPTION_FILENAME_VALIDATION, "report", true, "(optional): writes a validation report to the given filename. " + "Free naming, but should look like this: '<filename>.html'"); validate.setRequired(false); validate.setArgName("filename"); oh.addOption(validate); Option export = new Option(OPTION_FILENAME_DOT, "export", true, "(optional): writes a GraphViz DOT file to the given filename. " + "Free naming, but should look like this: '<filename>.dot'"); export.setRequired(false); export.setArgName("filename"); oh.addOption(export); Option schemaGraph = new Option(OPTION_FILENAME_SCHEMA_GRAPH, "schemaGraph", true, "(optional): writes a TG-file of the Schema as graph instance to the given filename. " + "Free naming, but should look like this: '<filename>.tg'"); schemaGraph.setRequired(false); schemaGraph.setArgName("filename"); oh.addOption(schemaGraph); Option input = new Option("i", "input", true, "(required): UML 2.1-XMI exchange model file of the Schema."); input.setRequired(true); input.setArgName("filename"); oh.addOption(input); Option output = new Option(OPTION_FILENAME_SCHEMA, "output", true, "(optional): writes a TG-file of the Schema to the given filename. " + "Free naming, but should look like this: '<filename>.rsa.tg.'"); output.setRequired(false); output.setArgName("filename"); oh.addOption(output); Option fromRole = new Option(OPTION_USE_ROLE_NAME, "useFromRole", false, "(optional): if this flag is set, the name of from roles will be used for creating undefined EdgeClass names."); fromRole.setRequired(false); oh.addOption(fromRole); Option unusedDomains = new Option(OPTION_REMOVE_UNUSED_DOMAINS, "removeUnusedDomains", false, "(optional): if this flag is set, all unused domains be deleted."); unusedDomains.setRequired(false); oh.addOption(unusedDomains); Option emptyPackages = new Option(OPTION_KEEP_EMPTY_PACKAGES, "keepEmptyPackages", false, "(optional): if this flag is set, empty packages will be retained."); unusedDomains.setRequired(false); oh.addOption(emptyPackages); Option navigability = new Option(OPTION_USE_NAVIGABILITY, "useNavigability", false, "(optional): if this flag is set, navigability information will be interpreted as reading direction."); navigability.setRequired(false); oh.addOption(navigability); // Parses the given command line parameters with all created Option. return oh.parse(args); }