List of usage examples for org.apache.commons.cli OptionBuilder withDescription
public static OptionBuilder withDescription(String newDescription)
From source file:com.archivas.clienttools.arcmover.cli.ArcProfileMgr.java
@SuppressWarnings({ "static-access" }) public Options getOptions() { if (cliOptions == null) { Options options = new Options(); OptionGroup operations = new OptionGroup(); // *** Adding a new option needs to be added to the cliOrder list operations.addOption(OptionBuilder.withDescription("Displays this help text (the default behavior).") .withLongOpt("help").create("h")); operations.addOption(OptionBuilder.hasOptionalArg().withArgName("profile_name").withDescription( "Lists information about the specified namespace profile. If <profile_name> is omitted, lists information about all namespace profiles.") .withLongOpt("list").create("l")); operations.addOption(OptionBuilder.hasArg().withArgName("profile_name") .withDescription("Deletes the specified namespace profile.").withLongOpt("delete").create("d")); operations.addOption(OptionBuilder.hasArg().withArgName("profile_name") .withDescription("Creates a namespace profile with the specified name.").withLongOpt("create") .create("c")); options.addOptionGroup(operations); // List the valid profile types dynamically String profileTypesToString = "Type of namespace for which you are creating the namespace profile: "; for (ProfileType type : ProfileType.values()) { if (type != ProfileType.FILESYSTEM) { // Filesystem is already createdcd profileTypesToString += (type.toString() + " | "); }//from w w w .j av a 2s .c o m } profileTypesToString = profileTypesToString.substring(0, profileTypesToString.length() - 3); options.addOption(OptionBuilder.withArgName("profile_type").hasArg() .withDescription(profileTypesToString).withLongOpt("type").create()); options.addOption(OptionBuilder.withArgName("tenant_name").hasArg().withDescription( "Name of the tenant that owns the namespace for which you are creating the namespace profile.") .withLongOpt("tenant").create()); options.addOption(OptionBuilder.withArgName("namespace_name").hasArg() .withDescription("Name of the namespace for which you are creating the namespace profile.") .withLongOpt("namespace").create()); options.addOption(OptionBuilder.withArgName("username").hasArg() .withDescription("Username of the data access account to use for namespace access.") .withLongOpt("username").create()); options.addOption(OptionBuilder.withArgName("password").hasArg() .withDescription("Password of the data access account to use for namespace access.") .withLongOpt("password").create()); options.addOption(OptionBuilder.withArgName("hostname").hasArg() .withDescription("The fully qualified domain name of the HCP system.").withLongOpt("hostname") .create()); options.addOption( OptionBuilder.withDescription("Tells HCP-DM to use SSL when communicating with the HCP system.") .withLongOpt("ssl").create()); options.addOption(OptionBuilder.withDescription( "Tells HCP-DM to check whether custom metadata XML is well-formed prior to communicating with the HCP system.") .withLongOpt("check-cm").create()); options.addOption(OptionBuilder .withDescription("Log into namespace anonymously. Only valid with HCP 5.0 or later profile.") .withLongOpt("anon").create()); options.addOption(OptionBuilder.withDescription( "Does not test if the namespace configuration provided can access HCP while creating the profile.") .withLongOpt("notest").create()); options.addOption(OptionBuilder.withArgName("address1[,address2]...").hasArg().withDescription( "Comma-separated list of one or more IP addresses to use to connect to the HCP system. If omitted, HCP-DM uses the hostname.") .withLongOpt("ips").create()); if (ALLOW_PORT) { options.addOption(OptionBuilder.withArgName("port").hasArg() .withDescription("Port to connect to HCP on").withLongOpt("port").create()); } cliOptions = options; } return cliOptions; }
From source file:acromusashi.stream.example.ml.client.KMeansDrpcClient.java
/** * ???/* www . j a v a 2s . co m*/ * * @return ?? */ public static Options createOptions() { Options cliOptions = new Options(); // KMeansTopology OptionBuilder.hasArg(true); OptionBuilder.withArgName("KMeansTopology Conf Path"); OptionBuilder.withDescription("KMeansTopology Conf Path"); OptionBuilder.isRequired(true); Option confPathOption = OptionBuilder.create("c"); // LOF OptionBuilder.hasArg(true); OptionBuilder.withArgName("KMeans Data"); OptionBuilder.withDescription("KMeans Data"); OptionBuilder.isRequired(true); Option dataOption = OptionBuilder.create("d"); // OptionBuilder.withDescription("show help"); Option helpOption = OptionBuilder.create("h"); cliOptions.addOption(confPathOption); cliOptions.addOption(dataOption); cliOptions.addOption(helpOption); return cliOptions; }
From source file:acromusashi.stream.example.ml.client.LofDrpcClient.java
/** * ???// www. ja v a 2s .c o m * * @return ?? */ public static Options createOptions() { Options cliOptions = new Options(); // LofTopology OptionBuilder.hasArg(true); OptionBuilder.withArgName("LofTopology Conf Path"); OptionBuilder.withDescription("LofTopology Conf Path"); OptionBuilder.isRequired(true); Option confPathOption = OptionBuilder.create("c"); // LOF OptionBuilder.hasArg(true); OptionBuilder.withArgName("LOF Data"); OptionBuilder.withDescription("LOF Data"); OptionBuilder.isRequired(true); Option dataOption = OptionBuilder.create("d"); // OptionBuilder.withDescription("show help"); Option helpOption = OptionBuilder.create("h"); cliOptions.addOption(confPathOption); cliOptions.addOption(dataOption); cliOptions.addOption(helpOption); return cliOptions; }
From source file:it.crs4.seal.read_sort.MergeAlignments.java
/** * Scan command line and set configuration values appropriately. * Calls System.exit in case of a command line error. *//* www . ja v a 2 s.c o m*/ @SuppressWarnings("static") // for OptionBuilder private void scanOptions(String[] args) { Options options = new Options(); Option ref = OptionBuilder.withDescription("root path to the reference used to create the SAM data") .hasArg().withArgName("REF_PATH").withLongOpt("reference").create("ref"); options.addOption(ref); Option ann = OptionBuilder.withDescription( "annotation file (.ann) of the BWA reference used to create the SAM data (not required if you specify " + ref.getOpt() + ")") .hasArg().withArgName("ref.ann").withLongOpt("annotations").create("ann"); options.addOption(ann); Option md5 = OptionBuilder.withDescription("generated MD5 checksums for reference contigs") .withLongOpt("md5").create("md5"); options.addOption(md5); Option optSortOrder = OptionBuilder.withDescription( "Sort order. Can be one of: unknown, unsorted, queryname, coordinate. Default: coordinate") .hasArg().withArgName("sort order").withLongOpt("sort-order").create("so"); options.addOption(optSortOrder); Option as = OptionBuilder.withDescription("Genome assembly identifier (@SQ AS:xxxx tag)").hasArg() .withArgName("ASSEMBLY_ID").withLongOpt("sq-assembly").create("sqas"); options.addOption(as); Option optHeaderOnly = OptionBuilder.withDescription("Only output the SAM header, then exit.") .withLongOpt("header-only").create("ho"); options.addOption(optHeaderOnly); // read group options Map<String, Option> readGroupOptions = defineRGOptions(); for (Option opt : readGroupOptions.values()) options.addOption(opt); CommandLineParser parser = new GnuParser(); try { CommandLine line = parser.parse(options, args); if (line.hasOption(ref.getOpt())) userReferenceRoot = line.getOptionValue(ref.getOpt()); if (line.hasOption(md5.getOpt())) generatedMd5 = true; if (line.hasOption(ann.getOpt())) userAnnotation = line.getOptionValue(ann.getOpt()); if (line.hasOption(as.getOpt())) // TODO: validate this input genomeAssemblyId = line.getOptionValue(as.getOpt()); if (line.hasOption(optSortOrder.getOpt())) { String value = line.getOptionValue(optSortOrder.getOpt()); if ("unknown".equals(value) || "unsorted".equals(value) || "queryname".equals(value) || "coordinate".equals(value)) sortOrder = value; else throw new ParseException( "Invalid sort order. Sort order must be one of: unknown, unsorted, queryname, coordinate."); } if (line.hasOption(optHeaderOnly.getOpt())) headerOnly = true; // remaining args String[] otherArgs = line.getArgs(); if (headerOnly) { // We're only generating the header, so we don't expect any input reads. if (otherArgs.length > 1) throw new ParseException( "You can't provide an input path with --header-only. Provide an output path or let the output go to stdout."); if (otherArgs.length == 0) userOutput = null; else userOutput = otherArgs[0]; } else // not headerOnly { if (otherArgs.length <= 0 || otherArgs.length > 2) throw new ParseException( "You must provide an HDFS input path and, optionally, an output path."); userOutput = null; userInput = otherArgs[0]; if (otherArgs.length >= 2) userOutput = otherArgs[1]; } readGroupFields = parseReadGroupOptions(readGroupOptions, line); // option validation if (generatedMd5 && userReferenceRoot == null) throw new ParseException( "You must specify the path the reference if you want to generate MD5 checksums"); if (userReferenceRoot == null && userAnnotation == null) throw new ParseException( "You must provide the path to the reference or at least its annotation file (<ref>.ann)"); } catch (ParseException e) { System.err.println("Usage error: " + e.getMessage()); // XXX: redirect System.out to System.err since the simple version of // HelpFormatter.printHelp prints to System.out, and we're on a way to // a fatal exit. System.setOut(System.err); HelpFormatter formatter = new HelpFormatter(); formatter.printHelp("MergeAlignments [options] -ann <ref>.ann [<in>] [<out>]", options); System.exit(1); } }
From source file:com.google.code.linkedinapi.client.examples.AsyncApiExample.java
/** * Build command line options object./* w w w .ja va 2 s. c om*/ */ private static Options buildOptions() { Options opts = new Options(); String helpMsg = "Print this message."; Option help = new Option(HELP_OPTION, helpMsg); opts.addOption(help); String consumerKeyMsg = "You API Consumer Key."; OptionBuilder.withArgName("consumerKey"); OptionBuilder.hasArg(); OptionBuilder.withDescription(consumerKeyMsg); Option consumerKey = OptionBuilder.create(CONSUMER_KEY_OPTION); opts.addOption(consumerKey); String consumerSecretMsg = "You API Consumer Secret."; OptionBuilder.withArgName("consumerSecret"); OptionBuilder.hasArg(); OptionBuilder.withDescription(consumerSecretMsg); Option consumerSecret = OptionBuilder.create(CONSUMER_SECRET_OPTION); opts.addOption(consumerSecret); String accessTokenMsg = "You OAuth Access Token."; OptionBuilder.withArgName("accessToken"); OptionBuilder.hasArg(); OptionBuilder.withDescription(accessTokenMsg); Option accessToken = OptionBuilder.create(ACCESS_TOKEN_OPTION); opts.addOption(accessToken); String tokenSecretMsg = "You OAuth Access Token Secret."; OptionBuilder.withArgName("accessTokenSecret"); OptionBuilder.hasArg(); OptionBuilder.withDescription(tokenSecretMsg); Option accessTokenSecret = OptionBuilder.create(ACCESS_TOKEN_SECRET_OPTION); opts.addOption(accessTokenSecret); String idMsg = "ID of the user whose connections are to be fetched."; OptionBuilder.withArgName("id"); OptionBuilder.hasArg(); OptionBuilder.withDescription(idMsg); Option id = OptionBuilder.create(ID_OPTION); opts.addOption(id); String emailMsg = "Email of the user whose connections are to be fetched."; OptionBuilder.withArgName("email"); OptionBuilder.hasArg(); OptionBuilder.withDescription(emailMsg); Option email = OptionBuilder.create(EMAIL_OPTION); opts.addOption(email); String urlMsg = "Profile URL of the user whose connections are to be fetched."; OptionBuilder.withArgName("url"); OptionBuilder.hasArg(); OptionBuilder.withDescription(urlMsg); Option url = OptionBuilder.create(URL_OPTION); opts.addOption(url); return opts; }
From source file:com.googleapis.ajax.services.example.ResourceBundleGenerator.java
/** * Builds the options./* w w w.j ava 2 s .c om*/ * * @return the options */ private static Options buildOptions() { Options opts = new Options(); String helpMsg = "Print this message."; Option help = new Option(HELP_OPTION, helpMsg); opts.addOption(help); String applicationKeyMsg = "You Application ID."; OptionBuilder.withArgName("appid"); OptionBuilder.hasArg(); OptionBuilder.withDescription(applicationKeyMsg); Option applicationKey = OptionBuilder.create(APPLICATION_KEY_OPTION); opts.addOption(applicationKey); String resourceMsg = "Path to the default resource bundle (without .properties)."; OptionBuilder.withArgName("resource"); OptionBuilder.hasArg(); OptionBuilder.withDescription(resourceMsg); Option resource = OptionBuilder.create(RESOURCE_OPTION); opts.addOption(resource); String languagesMsg = "Comma separated list of languages. e.g. de,fr,es"; OptionBuilder.withArgName("languages"); OptionBuilder.hasArg(); OptionBuilder.withDescription(languagesMsg); Option languages = OptionBuilder.create(LANGUAGES_OPTION); opts.addOption(languages); return opts; }
From source file:de.clusteval.data.randomizer.DataRandomizer.java
/** * Adds the default options of dataset generators to the given Options * attribute// www . j ava2s. co m * * @param options * The existing Options attribute, holding already the options of * the actual generator implementation. */ private void addDefaultOptions(final Options options) { OptionBuilder.withArgName("dataConfig"); OptionBuilder.isRequired(); OptionBuilder.hasArg(); OptionBuilder.withDescription("The name of the data configuration to randomize"); Option option = OptionBuilder.create("dataConfig"); options.addOption(option); }
From source file:mitm.application.djigzo.tools.Monitor.java
@SuppressWarnings("static-access") private Options createCommandLineOptions() { Options options = new Options(); userOption = OptionBuilder.withArgName("user").hasArg().withDescription("user").create("user"); userOption.setRequired(false);//from www . ja va 2 s.c o m options.addOption(userOption); passwordOption = OptionBuilder.withArgName("password").hasArg().withDescription("password") .create("password"); passwordOption.setRequired(false); options.addOption(passwordOption); passwordPromptOption = OptionBuilder.withDescription("ask for password").create("pwd"); passwordPromptOption.setRequired(false); options.addOption(passwordPromptOption); helpOption = OptionBuilder.withDescription("Show help").create("help"); helpOption.setRequired(false); options.addOption(helpOption); mpaSizeOption = OptionBuilder.withArgName("repository").hasArg() .withDescription("Returns the MPA mail queue size of [error, outgoing, spool, respool]") .create("mpasize"); mpaSizeOption.setRequired(false); options.addOption(mpaSizeOption); crlStoreSizeOption = OptionBuilder.withDescription("Returns the size of the CRL store").create("crlsize"); crlStoreSizeOption.setRequired(false); options.addOption(crlStoreSizeOption); runningOption = OptionBuilder.withDescription("Returns true if the back-end is running.").create("running"); options.addOption(runningOption); mtaSizeOption = OptionBuilder.withDescription("Returns the MTA mail queue size").create("mtasize"); options.addOption(mtaSizeOption); certStoreSizeOption = OptionBuilder.withDescription("Returns the certificate store size") .create("certsize"); options.addOption(certStoreSizeOption); certRequestStoreSizeOption = OptionBuilder.withDescription("Returns the certificate request store size") .create("certrequestsize"); options.addOption(certRequestStoreSizeOption); smsSizeOption = OptionBuilder.withDescription("Returns the SMS queue size").create("smssize"); options.addOption(smsSizeOption); userSizeOption = OptionBuilder.withDescription("Returns the number of users").create("usersize"); options.addOption(userSizeOption); loggingOption = OptionBuilder.withDescription("If set, debug logging will be enabled").create("logging"); options.addOption(loggingOption); hostOption = OptionBuilder.withArgName("host").hasArg() .withDescription("The host to connect to (def: 127.0.0.1)").create("host"); options.addOption(hostOption); portOption = OptionBuilder.withArgName("port").hasArg() .withDescription("The port to use (def: " + DjigzoWSDefaults.PORT + ")").create("port"); options.addOption(portOption); return options; }
From source file:com.github.errantlinguist.latticevisualiser.ArgParser.java
/** * Creates and adds a state size multiplier option to a given * {@link Options} object./*from w w w .ja v a2 s . c om*/ * * @param options * The <code>Options</code> object to add to. */ private static void addStateSizeMultiplierOption(final Options options) { OptionBuilder.withLongOpt(STATE_SIZE_MULTIPLIER_KEY_LONG); OptionBuilder.withDescription(STATE_SIZE_MULTIPLIER_DESCR); OptionBuilder.hasArg(); OptionBuilder.withArgName(SIZE_ARG_NAME); OptionBuilder.withType(double.class); final Option stateSizeMultiplier = OptionBuilder.create(STATE_SIZE_MULTIPLIER_KEY); options.addOption(stateSizeMultiplier); }
From source file:de.vandermeer.skb.commons.utils.CLIApache.java
@Override public Com_Coin declareOptions(PropertyTable prop) { String optShort;/*from w ww .j ava2s . c o m*/ String optLong; CC_Warning ret = null; for (String current : prop.keys()) { if (prop.hasPropertyValue(current, EAttributeKeys.CLI_PARAMETER_TYPE)) { Object o = Skb_ObjectUtils.CONVERT(prop.get(current, EAttributeKeys.CLI_PARAMETER_LONG), Object.class, NONull.get, NONone.get); if (!(o instanceof Com_Coin)) { optLong = o.toString(); } else { optLong = null; } OptionBuilder.withLongOpt(optLong); o = Skb_ObjectUtils.CONVERT(prop.get(current, EAttributeKeys.CLI_PARAMETER_DESCRIPTION_SHORT), Object.class, NONull.get, NONone.get); OptionBuilder.withDescription(o.toString()); o = Skb_ObjectUtils.CONVERT(prop.get(current, EAttributeKeys.CLI_PARAMETER_DESCRIPTION_ARGUMENTS), Object.class, NONull.get, NONone.get); if (!(o instanceof Com_Coin) && o.toString().length() > 0) { OptionBuilder.hasArg(); OptionBuilder.withArgName(o.toString()); } else { OptionBuilder.hasArg(false); } switch (this.typeMap .getPair4Source(prop.get(current, EAttributeKeys.CLI_PARAMETER_TYPE).toString())) { case JAVA_BOOLEAN: OptionBuilder.withType(Boolean.class); break; case JAVA_DOUBLE: OptionBuilder.withType(Double.class); break; case JAVA_INTEGER: OptionBuilder.withType(Integer.class); break; case JAVA_LONG: OptionBuilder.withType(Long.class); break; case JAVA_STRING: default: OptionBuilder.withType(String.class); break; } o = prop.get(current, EAttributeKeys.CLI_PARAMETER_SHORT); if (o != null && !(o instanceof Com_Coin)) { optShort = o.toString(); } else { optShort = null; } if (optShort != null && optLong != null) { this.options.addOption(OptionBuilder.create(optShort.charAt(0))); this.optionList.put(current, optLong); } else if (optLong != null) { this.options.addOption(OptionBuilder.create()); this.optionList.put(current, optLong); } else { //dummy create, nothing to be done since no option set (short/long) OptionBuilder.withLongOpt("__dummyLongOpt__"); OptionBuilder.create(); if (ret == null) { ret = new CC_Warning(); } ret.add(new Message5WH_Builder().addWhat("no short and no long options for <").addWhat(current) .addWhat(">").build()); } } } if (ret == null) { return NOSuccess.get; } return ret; }