List of usage examples for org.apache.commons.cli Option setValueSeparator
public void setValueSeparator(char sep)
From source file:org.duracloud.chunk.FileChunkerDriver.java
private static Options getOptions() { Option username = new Option("u", "username", true, "username of duracloud instance"); username.setArgs(1);//from www . j a va 2 s . c om username.setArgName("username"); Option password = new Option("p", "password", true, "password of duracloud instance"); password.setArgs(1); password.setArgName("password"); Option create = new Option("g", "generate", true, "generate test data to <outFile> of " + "<size> bytes"); create.setArgs(2); create.setArgName("outFile numBytes"); create.setValueSeparator(' '); Option add = new Option("a", "add", true, "add content from dir:<f> to space:<t> of max" + " chunk size:<s> in units of K,M,G"); add.setArgs(3); add.setArgName("f t s{K|M|G}"); add.setValueSeparator(' '); Option fileFiltered = new Option("f", "file-filter", true, "limit processed files to those " + "listed in file-list:<l>"); fileFiltered.setArgs(1); fileFiltered.setArgName("l"); Option dirFiltered = new Option("d", "dir-filter", true, "limit processed directories to " + "those listed in file-list:<l>"); dirFiltered.setArgs(1); dirFiltered.setArgName("l"); Option cloud = new Option("c", "cloud-store", true, "use cloud store found at <host>:<port> " + "as content dest"); cloud.setArgs(2); cloud.setArgName("host:port"); cloud.setValueSeparator(':'); Option excludeChunkMD5s = new Option("x", "exclude-chunk-md5s", false, "if this option is set, chunk " + "MD5s will NOT be preserved " + "in the manifest"); Option ignoreLargeFiles = new Option("i", "ignore-large-files", false, "if this option is set, files " + "over the chunk size " + "specified in the 'add' " + "option will be ignored."); Options options = new Options(); options.addOption(username); options.addOption(password); options.addOption(create); options.addOption(add); options.addOption(fileFiltered); options.addOption(dirFiltered); options.addOption(cloud); options.addOption(excludeChunkMD5s); options.addOption(ignoreLargeFiles); return options; }
From source file:org.esa.cci.sst.tools.BasicTool.java
private static Options createCommandLineOptions() { final Option helpOpt = new Option("help", "print this message"); final Option versionOpt = new Option("version", "print the version information and exit"); final Option verboseOpt = new Option("verbose", "be extra verbose"); final Option debugOpt = new Option("debug", "print debugging information"); final Option confFileOpt = new Option(CONFIG_FILE_OPTION_NAME, "alternative configuration file"); confFileOpt.setArgs(1);//from w ww . j a va 2 s .co m confFileOpt.setArgName("file"); confFileOpt.setType(File.class); final Option propertyOpt = new Option("D", "use value for given property"); propertyOpt.setValueSeparator('='); propertyOpt.setArgName("property=value"); propertyOpt.setArgs(2); Options options = new Options(); options.addOption(helpOpt); options.addOption(versionOpt); options.addOption(verboseOpt); options.addOption(debugOpt); options.addOption(confFileOpt); options.addOption(propertyOpt); return options; }
From source file:org.fusesource.mop.support.OptionBuilder.java
public Option op() { Option option = new Option(id != null ? id : " ", name, arg != null || args > 0, description); option.setRequired(required);/*from w w w. j a va 2 s .c o m*/ option.setType(type); option.setValueSeparator(sperator); if (arg != null && args == -1) { args = 1; } option.setArgs(args); option.setArgName(arg); return option; }
From source file:org.jcryptool.commands.core.api.OptionsBuilder.java
public OptionsBuilder addOption(String longOption, String shortOption, boolean required, String description, String argName, boolean argRequired, char argValueSeparator, int argsCount) { Option option = new Option(shortOption, longOption, true, description); option.setArgName(argName);/* ww w . j a v a 2 s.co m*/ option.setRequired(required); option.setOptionalArg(argRequired); option.setValueSeparator(argValueSeparator); option.setArgs(argsCount); options.add(option); return this; }
From source file:org.onebusaway.quickstart.bootstrap.WebappBootstrapMain.java
private static Options createOptions() { Options options = new Options(); options.addOption(ARG_PORT, true, "port (default=8080)"); options.addOption(WebappCommon.ARG_BUILD, false, ""); options.addOption(WebappCommon.ARG_GTFS_PATH, true, ""); options.addOption(WebappCommon.ARG_GTFS_REALTIME_TRIP_UPDATES_URL, true, ""); options.addOption(WebappCommon.ARG_GTFS_REALTIME_VEHICLE_POSITIONS_URL, true, ""); options.addOption(WebappCommon.ARG_GTFS_REALTIME_ALERTS_URL, true, ""); options.addOption(WebappCommon.ARG_GTFS_REALTIME_REFRESH_INTERVAL, true, ""); Option pOption = new Option("P", "use value for given property"); pOption.setArgName("beanName.beanProperty=value"); pOption.setArgs(2);// w ww. ja v a 2 s . c o m pOption.setValueSeparator('='); options.addOption(pOption); return options; }
From source file:org.onebusaway.transit_data_federation.bundle.FederatedTransitDataBundleCreatorMain.java
protected void buildOptions(Options options) { options.addOption(ARG_SKIP_TO, true, ""); options.addOption(ARG_ONLY, true, ""); options.addOption(ARG_SKIP, true, ""); options.addOption(ARG_INCLUDE, true, ""); options.addOption(ARG_ONLY_IF_DNE, false, ""); options.addOption(ARG_DATASOURCE_DRIVER_CLASS_NAME, true, ""); options.addOption(ARG_DATASOURCE_URL, true, ""); options.addOption(ARG_DATASOURCE_USERNAME, true, ""); options.addOption(ARG_DATASOURCE_PASSWORD, true, ""); options.addOption(ARG_BUNDLE_KEY, true, ""); options.addOption(ARG_RANDOMIZE_CACHE_DIR, false, ""); options.addOption(ARG_ADDITIONAL_RESOURCES_DIRECTORY, true, ""); options.addOption(ARG_OSM, true, ""); Option dOption = new Option("D", "use value for given property"); dOption.setArgName("property=value"); dOption.setArgs(2);//ww w . j a v a2 s .co m dOption.setValueSeparator('='); options.addOption(dOption); Option pOption = new Option("P", "use value for given property"); pOption.setArgName("beanName.beanProperty=value"); pOption.setArgs(2); pOption.setValueSeparator('='); options.addOption(pOption); }
From source file:org.seedstack.seed.core.internal.cli.CliModel.java
CliModel(Set<Field> fields) { for (Field field : fields) { CliOption optionAnnotation = field.getAnnotation(CliOption.class); CliArgs argsAnnotation = field.getAnnotation(CliArgs.class); if (optionAnnotation != null) { Option option = new Option(optionAnnotation.name(), optionAnnotation.longName(), optionAnnotation.valueCount() > 0 || optionAnnotation.valueCount() == -1, optionAnnotation.description()); if (optionAnnotation.valueCount() == -1) { option.setArgs(Option.UNLIMITED_VALUES); } else if (optionAnnotation.valueCount() > 0) { option.setArgs(optionAnnotation.valueCount()); }//from www .ja v a 2 s. c o m option.setValueSeparator(optionAnnotation.valueSeparator()); option.setRequired(optionAnnotation.mandatory()); option.setOptionalArg(!optionAnnotation.mandatoryValue()); optionAnnotations.add(optionAnnotation); optionFields.add(field); options.addOption(option); } else if (argsAnnotation != null) { mandatoryArgsCount = argsAnnotation.mandatoryCount(); argsField = field; } } }
From source file:org.uli.util.MyOptionBuilder.java
/** * Create an Option using the current settings and with * the specified Option <code>char</code>. * * @param opt the <code>java.lang.String</code> representation * of the Option/* ww w . j a va2 s.com*/ * @return the Option instance * @throws IllegalArgumentException if <code>opt</code> is not * a valid character. See Option. */ public Option create(String opt) throws IllegalArgumentException { Option option = null; try { // create the option option = new Option(opt, description); // set the option properties option.setLongOpt(longopt); option.setRequired(required); option.setOptionalArg(optionalArg); option.setArgs(numberOfArgs); option.setType(type); option.setValueSeparator(valuesep); option.setArgName(argName); } finally { // reset the OptionBuilder properties this.reset(); } // return the Option instance return option; }
From source file:org.wildfly.security.tool.VaultCommand.java
public VaultCommand() { options = new Options(); // PB vault related options Option o = new Option("k", KEYSTORE_PARAM, true, ElytronToolMessages.msg.cmdLineVaultKeyStoreURL()); o.setArgName(KEYSTORE_PARAM);/*from www .j a v a 2s .c o m*/ options.addOption(o); o = new Option("p", KEYSTORE_PASSWORD_PARAM, true, ElytronToolMessages.msg.cmdLineVaultKeyStorePassword()); o.setArgName("pwd"); options.addOption(o); o = new Option("e", ENC_DIR_PARAM, true, ElytronToolMessages.msg.cmdLineVaultEncryptionDirectory()); o.setArgName("dir"); options.addOption(o); o = new Option("s", SALT_PARAM, true, ElytronToolMessages.msg.cmdVaultLineSalt()); o.setArgName("salt"); options.addOption(o); o = new Option("i", ITERATION_PARAM, true, ElytronToolMessages.msg.cmdLineVaultIterationCount()); options.addOption(o); o = new Option("v", ALIAS_PARAM, true, ElytronToolMessages.msg.cmdLineVaultKeyStoreAlias()); options.addOption(o); // Credential Store generation options o = new Option("l", STORE_LOCATION_PARAM, true, ElytronToolMessages.msg.cmdLineVaultCSLocationDesc()); o.setArgName("loc"); options.addOption(o); o = new Option("u", CredentialStoreCommand.IMPLEMENTATION_PROPERTIES_PARAM, true, ElytronToolMessages.msg.cmdLineVaultCSParametersDesc()); o.setValueSeparator(';'); o.setOptionalArg(true); options.addOption(o); o = new Option("t", CredentialStoreCommand.CREDENTIAL_STORE_TYPE_PARAM, true, ElytronToolMessages.msg.cmdLineVaultCSTypeDesc()); o.setArgName("type"); options.addOption(o); o = new Option("o", CredentialStoreCommand.OTHER_PROVIDERS_PARAM, true, ElytronToolMessages.msg.cmdLineOtherProvidersDesc()); o.setArgName("providers"); o.setOptionalArg(true); options.addOption(o); o = new Option("q", CredentialStoreCommand.CUSTOM_CREDENTIAL_STORE_PROVIDER_PARAM, true, ElytronToolMessages.msg.cmdLineCustomCredentialStoreProviderDesc()); o.setArgName("cs-provider"); o.setOptionalArg(true); options.addOption(o); options.addOption("f", PRINT_SUMMARY_PARAM, false, ElytronToolMessages.msg.cmdLineVaultPrintSummary()); Option b = new Option("b", BULK_CONVERT_PARAM, true, ElytronToolMessages.msg.cliCommandBulkVaultCredentialStoreConversion()); b.setArgName("description file"); Option h = new Option("h", HELP_PARAM, false, ElytronToolMessages.msg.cmdLineHelp()); Option d = new Option("d", DEBUG_PARAM, false, ElytronToolMessages.msg.cmdLineDebug()); options.addOption(b); options.addOption(h); options.addOption(d); }
From source file:treecmp.commandline.CommandLineParser.java
public Command run(String args[]) { Command cmd = null;//from w w w .j av a 2s. co m DefinedMetricsSet DMSet = DefinedMetricsSet.getInstance(); Option oS = new Option("s", S_DESC); Option oW = new Option("w", W_DESC); oW.setArgName(W_ARG); oW.setArgs(1); Option oM = new Option("m", M_DESC); Option oR = new Option("r", R_DESC); oR.setArgName(R_ARG); oR.setArgs(1); OptionGroup cmdOpts = new OptionGroup(); cmdOpts.addOption(oS); cmdOpts.addOption(oW); cmdOpts.addOption(oM); cmdOpts.addOption(oR); cmdOpts.setRequired(true); //set metric option Option oD = new Option("d", D_DESC); oD.setArgName(D_ARG); oD.setValueSeparator(' '); oD.setArgs(DMSet.size()); oD.setRequired(true); Option oI = new Option("i", I_DESC); oI.setArgName(I_ARG); oI.setArgs(1); oI.setRequired(true); Option oO = new Option("o", O_DESC); oO.setArgs(1); oO.setArgName(O_ARG); oO.setRequired(true); Option oP = new Option("P", P_DESC); Option oSS = new Option("N", SS_DESC); Option oII = new Option("I", II_DESC); Option oOO = new Option("O", OO_DESC); Option oA = new Option("A", A_DESC); OptionGroup customMOpts = new OptionGroup(); customMOpts.addOption(oOO); customMOpts.addOption(oA); Options opts = new Options(); opts.addOptionGroup(cmdOpts); opts.addOption(oD); opts.addOption(oI); opts.addOption(oO); opts.addOption(oP); opts.addOption(oSS); opts.addOption(oII); opts.addOptionGroup(customMOpts); //getting version from manifest file String version = CommandLineParser.class.getPackage().getImplementationVersion(); if (version == null) { version = ""; } String FOOTER = ""; String HEADER = " "; String APP_NAME = "TreeCmp version " + version + "\n"; GnuParser parser = new GnuParser(); HelpFormatter formatter = new HelpFormatter(); formatter.setOptionComparator(new OptOrder()); System.out.println(APP_NAME); if (args.length == 0) { formatter.printHelp(CMD_LINE_SYNTAX, HEADER, opts, FOOTER, false); return null; } try { CommandLine commandLine = parser.parse(opts, args); if (commandLine != null) { // process these values //set IO settings String inputFileName = (String) commandLine.getOptionValue(oI.getOpt()); String outputFileName = (String) commandLine.getOptionValue(oO.getOpt()); if (inputFileName == null) { System.out.println("Error: input file not specified!"); formatter.printHelp(CMD_LINE_SYNTAX, HEADER, opts, FOOTER, false); return null; } if (outputFileName == null) { System.out.println("Error: output file not specified!"); formatter.printHelp(CMD_LINE_SYNTAX, HEADER, opts, FOOTER, false); return null; } //commandLine. IOSettings IOset = IOSettings.getIOSettings(); IOset.setInputFile(inputFileName); IOset.setOutputFile(outputFileName); //custom additinal options ArrayList<Option> custOpts = new ArrayList<Option>(); if (commandLine.hasOption(oP.getOpt())) { IOset.setPruneTrees(true); custOpts.add(oP); } if (commandLine.hasOption(oSS.getOpt())) { IOset.setRandomComparison(true); custOpts.add(oSS); } if (commandLine.hasOption(oA.getOpt())) { IOset.setGenAlignments(true); custOpts.add(oA); } if (commandLine.hasOption(oOO.getOpt())) { IOset.setOptMsMcByRf(true); custOpts.add(oOO); } if (commandLine.hasOption(oII.getOpt())) { IOset.setGenSummary(true); custOpts.add(oII); } Collections.sort(custOpts, new OptOrder()); //set active metrics ActiveMetricsSet AMSet = ActiveMetricsSet.getInstance(); final String[] metrics = commandLine.getOptionValues(oD.getOpt()); for (int i = 0; i < metrics.length; i++) { final DefinedMetric definedMetric = DMSet.getDefinedMetric(metrics[i]); if (definedMetric != null) { AMSet.addMetric(definedMetric); } else { System.out.print("Error: "); System.out.println("Metric: " + metrics[i] + " is unknown\n."); formatter.printHelp(CMD_LINE_SYNTAX, HEADER, opts, FOOTER, false); return null; } } //set active command String analysisType = ""; if (commandLine.hasOption(oW.getOpt())) { String sWindowSize = (String) commandLine.getOptionValue(oW.getOpt()); int iWindowSize = Integer.parseInt(sWindowSize); cmd = new RunWCommand(1, "-w", iWindowSize); analysisType = "window comparison mode (-w) with window size: " + iWindowSize; } else if (commandLine.hasOption(oM.getOpt())) { cmd = new RunMCommand(0, "-m"); analysisType = "matrix comparison mode (-m)"; } else if (commandLine.hasOption(oS.getOpt())) { cmd = new RunSCommand(0, "-s"); analysisType = "overlapping pair comparison mode (-s)"; } else if (commandLine.hasOption(oR.getOpt())) { String sRefTreeFile = (String) commandLine.getOptionValue(oR.getOpt()); cmd = new RunRCommand(0, "-r", sRefTreeFile); analysisType = " ref-to-all comparison mode (-r)"; } else { System.out.println("Error: type of the analysis not specified correctly!"); formatter.printHelp(CMD_LINE_SYNTAX, HEADER, opts, FOOTER, false); return null; } printOptionsInEffect(analysisType, AMSet, inputFileName, outputFileName, custOpts); return cmd; } else { //Error during parsing command line return null; } } catch (ParseException ex) { log.log(Level.WARNING, "Could not parse command line arguments.", ex); System.out.println(CMD_ERROR); formatter.printHelp(CMD_LINE_SYNTAX, HEADER, opts, FOOTER, false); } catch (NumberFormatException ex) { System.out.print("Error: "); System.out.println("window size should be an integer.\n"); formatter.printHelp(CMD_LINE_SYNTAX, HEADER, opts, FOOTER, false); } return cmd; }