List of usage examples for org.apache.commons.cli Option setArgName
public void setArgName(String argName)
From source file:com.netscape.cmstools.cert.CertFindCLI.java
public void createOptions() { Option option = null; //pagination options option = new Option(null, "start", true, "Page start"); option.setArgName("start"); options.addOption(option);/*w w w . j a v a 2 s. co m*/ option = new Option(null, "size", true, "Page size"); option.setArgName("size"); options.addOption(option); //file input option = new Option(null, "input", true, "File containing the search constraints"); option.setArgName("file path"); options.addOption(option); //serialNumberinUse option = new Option(null, "minSerialNumber", true, "Minimum serial number"); option.setArgName("serial number"); options.addOption(option); option = new Option(null, "maxSerialNumber", true, "Maximum serial number"); option.setArgName("serial number"); options.addOption(option); //subjectNameinUse option = new Option(null, "name", true, "Subject's common name"); option.setArgName("name"); options.addOption(option); option = new Option(null, "email", true, "Subject's email address"); option.setArgName("email"); options.addOption(option); option = new Option(null, "uid", true, "Subject's userid"); option.setArgName("user id"); options.addOption(option); option = new Option(null, "org", true, "Subject's organization"); option.setArgName("name"); options.addOption(option); option = new Option(null, "orgUnit", true, "Subject's organization unit"); option.setArgName("name"); options.addOption(option); option = new Option(null, "locality", true, "Subject's locality"); option.setArgName("name"); options.addOption(option); option = new Option(null, "state", true, "Subject's state"); option.setArgName("name"); options.addOption(option); option = new Option(null, "country", true, "Subject's country"); option.setArgName("name"); options.addOption(option); options.addOption(null, "matchExactly", false, "Match exactly with the details provided"); //status option = new Option(null, "status", true, "Certificate status: VALID, INVALID, REVOKED, EXPIRED, REVOKED_EXPIRED"); option.setArgName("status"); options.addOption(option); //revokedByInUse option = new Option(null, "revokedBy", true, "Certificate revoked by"); option.setArgName("user id"); options.addOption(option); //revocationPeriod option = new Option(null, "revokedOnFrom", true, "Revoked on or after this date"); option.setArgName("YYYY-MM-DD"); options.addOption(option); option = new Option(null, "revokedOnTo", true, "Revoked on or before this date"); option.setArgName("YYYY-MM-DD"); options.addOption(option); //revocationReason option = new Option(null, "revocationReason", true, "Reason for revocation"); option.setArgName("reason"); options.addOption(option); //issuedBy option = new Option(null, "issuedBy", true, "Issued by"); option.setArgName("user id"); options.addOption(option); //issuedOn option = new Option(null, "issuedOnFrom", true, "Issued on or after this date"); option.setArgName("YYYY-MM-DD"); options.addOption(option); option = new Option(null, "issuedOnTo", true, "Issued on or before this date"); option.setArgName("YYYY-MM-DD"); options.addOption(option); //certTypeinUse option = new Option(null, "certTypeSubEmailCA", true, "Certifiate type: Subject Email CA"); option.setArgName("on|off"); options.addOption(option); option = new Option(null, "certTypeSubSSLCA", true, "Certificate type: Subject SSL CA"); option.setArgName("on|off"); options.addOption(option); option = new Option(null, "certTypeSecureEmail", true, "Certifiate Type: Secure Email"); option.setArgName("on|off"); options.addOption(option); option = new Option(null, "certTypeSSLClient", true, "Certifiate Type: SSL Client"); option.setArgName("on|off"); options.addOption(option); option = new Option(null, "certTypeSSLServer", true, "Certifiate Type: SSL Server"); option.setArgName("on|off"); options.addOption(option); //validationNotBeforeInUse option = new Option(null, "validNotBeforeFrom", true, "Valid not before start date"); option.setArgName("YYYY-MM-DD"); options.addOption(option); option = new Option(null, "validNotBeforeTo", true, "Valid not before end date"); option.setArgName("YYYY-MM-DD"); options.addOption(option); //validityNotAfterinUse option = new Option(null, "validNotAfterFrom", true, "Valid not after start date"); option.setArgName("YYYY-MM-DD"); options.addOption(option); option = new Option(null, "validNotAfterTo", true, "Valid not after end date"); option.setArgName("YYYY-MM-DD"); options.addOption(option); //validityLengthinUse option = new Option(null, "validityOperation", true, "Validity duration operation: \"<=\" or \">=\""); option.setArgName("operation"); options.addOption(option); option = new Option(null, "validityCount", true, "Validity duration count"); option.setArgName("count"); options.addOption(option); option = new Option(null, "validityUnit", true, "Validity duration unit: day, week, month (default), year"); option.setArgName("day|week|month|year"); options.addOption(option); }
From source file:BwaOptions.java
/** * Function to init the SparkBWA available options * @return An Options object containing the available options *//*from ww w. ja v a 2 s . c om*/ public Options initOptions() { Options options = new Options(); //Algorithm options Option algorithm = new Option("algorithm", true, "Specify the algorithm to use during the alignment"); algorithm.setArgName("mem|aln|bwasw"); options.addOption(algorithm); //Paired or single reads Option reads = new Option("reads", true, "Type of reads to use during alignment"); reads.setArgName("paired|single"); options.addOption(reads); // Options to BWA Option bwaArgs = new Option("bwaArgs", true, "Arguments passed directly to BWA"); bwaArgs.setArgName("\"BWA arguments\""); options.addOption(bwaArgs); //Reducer option Option reducer = new Option("r", false, "Enables the reducer phase - setUseReducer(boolean)"); options.addOption(reducer); //Index Option index = new Option("index", true, "Prefix for the index created by bwa to use - setIndexPath(string)"); index.setArgName("Index prefix"); options.addOption(index); //Partition number Option partitions = new Option("partitions", true, "Number of partitions to divide input reads - setPartitionNumber(int)"); partitions.setArgName("Number of partitions"); options.addOption(partitions); Option sorting = new Option("sorting", true, "Type of algorithm used to sort input FASTQ reads"); sorting.setArgName("hdfs|spark"); options.addOption(sorting); return options; }
From source file:it.jnrpe.plugins.factory.COption.java
Option toOption() { Option ret = new Option(m_sOption, m_sDescription); if (m_bArgsOptional != null) ret.setOptionalArg(m_bArgsOptional.booleanValue()); if (m_bHasArgs) { if (m_iArgsCount == null) ret.setArgs(Option.UNLIMITED_VALUES); }//from w w w .ja va2 s . co m ret.setRequired(m_bRequired); if (m_iArgsCount != null) ret.setArgs(m_iArgsCount.intValue()); if (m_sArgName != null) { if (m_iArgsCount == null) ret.setArgs(Option.UNLIMITED_VALUES); ret.setArgName(m_sArgName); } if (m_sLongOpt != null) ret.setLongOpt(m_sLongOpt); if (m_sValueSeparator != null && m_sValueSeparator.length() != 0) ret.setValueSeparator(m_sValueSeparator.charAt(0)); return ret; }
From source file:edu.cornell.med.icb.geo.tools.Affy2InsightfulMiner.java
private void proccess(final String[] args) { // create the Options final Options options = new Options(); // help/*www.ja va2 s . co m*/ options.addOption("h", "help", false, "print this message"); // input file name final Option inputOption = new Option("il", "input-list", true, "specify the name of the input file list. This file tab-separated with two columns. Each row must indicate: (1) filename for an Affymetrix text file for one sample, (2) sample ID."); inputOption.setArgName("input-file-list"); inputOption.setRequired(true); options.addOption(inputOption); // output file name final Option outputOption = new Option("o", "output", true, "specify the destination file"); outputOption.setArgName("file"); outputOption.setRequired(true); options.addOption(outputOption); // label values final Option labelOptions = new Option("cl", "class-label", true, "specify how to set the label of samples"); labelOptions.setArgName("attribute,value,label"); labelOptions.setRequired(false); options.addOption(labelOptions); // group file names final Option groupOptions = new Option("sa", "sample-attributes", true, "specify a file that associates attributes to samples. The file is tab delimited. The first column of this file is the the sample ID. Additional columns indicate the value of the attributes named in the first line (name of sample ID is can be arbitrary and will be ignored)."); groupOptions.setArgName("file"); groupOptions.setRequired(false); options.addOption(groupOptions); // default label value final Option defaultLabelOption = new Option("dl", "default-label", true, "Specify the label to use for columns that are not identified by -l -g pairs. Default value is zero."); groupOptions.setArgName("double-value"); groupOptions.setRequired(false); // platform description final Option platformDescriptionFileOption = new Option("pd", "platform-description", true, "The platform description is a GEO platform description file that is used to link probe set ids to genbank identifiers. When a platform description file is provided, the second column in the output will contain the desired indentifier (default genbank)."); groupOptions.setArgName("file"); groupOptions.setRequired(false); options.addOption(platformDescriptionFileOption); // parse the command line arguments CommandLine line = null; double defaultLabelValue = 0; try { // create the command line parser final CommandLineParser parser = new BasicParser(); line = parser.parse(options, args, true); if ((line.hasOption("cl") && !line.hasOption("sa")) || (line.hasOption("sa") && !line.hasOption("cl"))) { System.err.println("Options -class-label and -sample-attributes must be used together."); System.exit(10); } if (line.hasOption("dl")) { defaultLabelValue = Double.parseDouble(line.getOptionValue("dl")); } } 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 { readInputList(line.getOptionValue("il")); readSampleAttributes(line.getOptionValue("sa")); final String platformFilename = line.getOptionValue("pd"); System.out.println("Reading platformFileContent description file " + platformFilename); platform = new GEOPlatform(); platform.read(platformFilename); System.out.println("Successfully read " + platform.getProbesetCount() + " probe set -> secondary identifier pairs."); readAndAssembleSamples(line.getOptionValues("cl"), defaultLabelValue, line.getOptionValue("o")); System.exit(0); } catch (Exception e) { e.printStackTrace(); System.exit(10); } }
From source file:com.flyhz.avengers.framework.AvengersClient.java
AvengersClient(Configuration conf) { batchId = System.currentTimeMillis(); LOG.info("conf is {},batchId is {}", batchId, conf); this.conf = conf; System.setProperty("HADOOP_USER_NAME", "avengers"); yarnClient = YarnClient.createYarnClient(); conf.getSocketAddr(YarnConfiguration.RM_ADDRESS, YarnConfiguration.DEFAULT_RM_ADDRESS, YarnConfiguration.DEFAULT_RM_PORT); yarnClient.init(conf);// ww w. j a v a 2 s .co m opts = new Options(); opts.addOption("jar", true, "Jar file containing the application master"); Option all = new Option("all", false, "avengers all:include crawl fetch analyze"); all.setArgs(0); Option crawl = new Option("crawl", true, "avengers crawl"); crawl.setArgs(1); crawl.setArgName("batchId"); Option fetch = new Option("fetch", true, "avengers fetch"); fetch.setArgs(1); fetch.setArgName("batchId"); Option analyze = new Option("analyze", true, "avengers analyze"); analyze.setArgs(1); analyze.setArgName("batchId"); opts.addOption(all); opts.addOption(crawl); opts.addOption(fetch); opts.addOption(analyze); avengersProcessCmds = new LinkedHashMap<String, List<String>>(); this.hdfsPath = "avengers/" + batchId + "/avengers.jar"; }
From source file:henplus.commands.SQLCommand.java
@Override public Collection<Option> getHandledCommandLineOptions() { final Collection<Option> result = new LinkedList<Option>(); final Option option = new Option("S", "SQL", true, "SQL to execute"); option.setArgName("SELECT ..."); result.add(option);//w w w .j av a 2s .c o m return result; }
From source file:com.netscape.cmstools.cli.MainCLI.java
public void createOptions() throws UnknownHostException { Option option = new Option("U", true, "Server URL"); option.setArgName("uri"); options.addOption(option);// w w w .j a va 2 s . com option = new Option("P", true, "Protocol (default: http)"); option.setArgName("protocol"); options.addOption(option); option = new Option("h", true, "Hostname (default: " + InetAddress.getLocalHost().getCanonicalHostName() + ")"); option.setArgName("hostname"); options.addOption(option); option = new Option("p", true, "Port (default: 8080)"); option.setArgName("port"); options.addOption(option); option = new Option("t", true, "Subsystem type (deprecated)"); option.setArgName("type"); options.addOption(option); option = new Option("d", true, "NSS database location (default: ~/.dogtag/nssdb)"); option.setArgName("database"); options.addOption(option); option = new Option("c", true, "NSS database password (mutually exclusive to -C and -f options)"); option.setArgName("password"); options.addOption(option); option = new Option("C", true, "NSS database password file (mutually exclusive to -c and -f options)"); option.setArgName("password file"); options.addOption(option); option = new Option("f", true, "NSS database password configuration (mutually exclusive to -c and -C options)"); option.setArgName("password config"); options.addOption(option); option = new Option("n", true, "Nickname for client certificate authentication (mutually exclusive to -u option)"); option.setArgName("nickname"); options.addOption(option); option = new Option("u", true, "Username for basic authentication (mutually exclusive to -n option)"); option.setArgName("username"); options.addOption(option); option = new Option("w", true, "Password for basic authentication (mutually exclusive to -W option)"); option.setArgName("password"); options.addOption(option); option = new Option("W", true, "Password file for basic authentication (mutually exclusive to -w option)"); option.setArgName("passwordfile"); options.addOption(option); option = new Option(null, "token", true, "Security token name"); option.setArgName("token"); options.addOption(option); option = new Option(null, "output", true, "Folder to store HTTP messages"); option.setArgName("folder"); options.addOption(option); option = new Option(null, "reject-cert-status", true, "Comma-separated list of rejected certificate validity statuses"); option.setArgName("list"); options.addOption(option); option = new Option(null, "ignore-cert-status", true, "Comma-separated list of ignored certificate validity statuses"); option.setArgName("list"); options.addOption(option); option = new Option(null, "ignore-banner", false, "Ignore access banner"); options.addOption(option); option = new Option(null, "message-format", true, "Message format: xml (default), json"); option.setArgName("format"); options.addOption(option); options.addOption("v", "verbose", false, "Run in verbose mode."); options.addOption(null, "help", false, "Show help message."); options.addOption(null, "version", false, "Show version number."); }
From source file:com.zimbra.soap.SoapCommandUtil.java
SoapCommandUtil() { // Initialize options. mOptions.addOption(new Option("h", LO_HELP, false, "Display this help message.")); Option opt = new Option("m", LO_MAILBOX, true, "Send mail and account requests to this account. " + "Also used for authentication if --auth, -a and -z are not specified."); opt.setArgName("account-name"); mOptions.addOption(opt);/* w ww . ja va2s. co m*/ opt = new Option(null, LO_AUTH, true, "Account name to authenticate as. Defaults to account in -m."); opt.setArgName("account-name"); mOptions.addOption(opt); mOptions.addOption(new Option("A", LO_ADMIN_PRIV, false, "Execute requests with admin privileges.")); opt = new Option("a", LO_ADMIN, true, "Admin account name to authenticate as."); opt.setArgName("account-name"); mOptions.addOption(opt); opt = new Option("p", LO_PASSWORD, true, "Password."); opt.setArgName("password"); mOptions.addOption(opt); opt = new Option("P", LO_PASSFILE, true, "Read password from file."); opt.setArgName("path"); mOptions.addOption(opt); opt = new Option("u", LO_URL, true, "SOAP service URL, usually " + "http[s]://host:port/service/soap or https://host:port/service/admin/soap."); opt.setArgName("url"); mOptions.addOption(opt); mOptions.addOption(new Option("z", LO_ZADMIN, false, "Authenticate with zimbra admin name/password from localconfig.")); mOptions.addOption(new Option("v", LO_VERBOSE, false, "Print the request.")); mOptions.addOption(new Option("vv", LO_VERY_VERBOSE, false, "Print URLs and all requests and responses with envelopes.")); mOptions.addOption(new Option("n", LO_NO_OP, false, "Print the SOAP request only. Don't send it.")); opt = new Option(null, LO_SELECT, true, "Select an element or attribute from the response."); opt.setArgName("xpath"); mOptions.addOption(opt); mOptions.addOption(new Option(null, LO_JSON, false, "Use JSON instead of XML. (Switches on --jaxb option by default).")); mOptions.addOption( new Option(null, LO_JAXB, false, "Force use of JAXB to aid building request from command line.")); mOptions.addOption(new Option(null, LO_NO_JAXB, false, "Disallow use of JAXB to aid building request from command line.")); opt = new Option("f", LO_FILE, true, "Read request from file. For JSON, the request pair should be the child of the root object."); opt.setArgName("path"); mOptions.addOption(opt); String types = StringUtil.join(",", sTypeToNamespace.keySet()); opt = new Option("t", LO_TYPE, true, "SOAP request type: " + types + ". Default is admin, or mail if -m is specified."); opt.setArgName("type"); mOptions.addOption(opt); mOptions.addOption(new Option(null, LO_USE_SESSION, false, "Use a SOAP session.")); mOptions.addOption(new Option(null, LO_TOTP, true, "TOTP token for two-factor auth")); try { mOut = new PrintStream(System.out, true, "utf-8"); } catch (UnsupportedEncodingException e) { } }
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();//from ww w .ja v a 2s . 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:de.bmw.yamaica.common.console.CommandExecuter.java
private Option createOption(IConfigurationElement optionConfiguration) { String shortName = optionConfiguration.getAttribute(OPTION_SHORT_NAME_ATTRIBUTE_NAME); String longName = optionConfiguration.getAttribute(OPTION_LONG_NAME_ATTRIBUTE_NAME); String description = optionConfiguration.getAttribute(OPTION_DESCRIPTION_ATTRIBUTE_NAME); String required = optionConfiguration.getAttribute(OPTION_REQUIRED_ATTRIBUTE_NAME); String argCount = optionConfiguration.getAttribute(OPTION_ARG_COUNT_ATTRIBUTE_NAME); String argName = optionConfiguration.getAttribute(OPTION_ARG_NAME_ATTRIBUTE_NAME); String hasOptionalArg = optionConfiguration.getAttribute(OPTION_HAS_OPTIONAL_ARG_ATTRIBUTE_NAME); String valueSeparator = optionConfiguration.getAttribute(OPTION_VALUE_SEPARATOR_ATTRIBUTE_NAME); Option option = new Option(shortName, description); option.setRequired(Boolean.parseBoolean(required)); option.setArgs(Integer.parseInt(argCount)); option.setOptionalArg(Boolean.parseBoolean(hasOptionalArg)); if (null != longName) { option.setLongOpt(longName);// www . ja v a 2s . c o m } if (null != argName) { option.setArgName(argName); } if (null != valueSeparator) { option.setValueSeparator(valueSeparator.charAt(0)); } return option; }