List of usage examples for org.apache.commons.cli Option setArgs
public void setArgs(int num)
From source file:org.springframework.amqp.rabbit.MulticastMain.java
private static Options getOptions() { Options options = new Options(); options.addOption(new Option("?", "help", false, "show usage")); options.addOption(new Option("h", "host", true, "broker host")); options.addOption(new Option("p", "port", true, "broker port")); options.addOption(new Option("t", "type", true, "exchange type")); options.addOption(new Option("e", "exchange", true, "exchange name")); options.addOption(new Option("i", "interval", true, "sampling interval")); options.addOption(new Option("r", "rate", true, "rate limit")); options.addOption(new Option("N", "messages", true, "message count")); options.addOption(new Option("c", "connections", false, "share consumer connections")); options.addOption(new Option("x", "producers", true, "producer count")); options.addOption(new Option("y", "consumers", true, "consumer count")); options.addOption(new Option("m", "ptxsize", true, "producer tx size")); options.addOption(new Option("n", "ctxsize", true, "consumer tx size")); options.addOption(new Option("a", "autoack", false, "auto ack")); options.addOption(new Option("q", "qos", true, "qos prefetch count")); options.addOption(new Option("s", "size", true, "message size")); options.addOption(new Option("z", "time", true, "time limit")); Option flag = new Option("f", "flag", true, "message flag"); flag.setArgs(Option.UNLIMITED_VALUES); options.addOption(flag);//from www. j a v a2 s . c o m options.addOption(new Option("M", "framemax", true, "frame max")); options.addOption(new Option("b", "heartbeat", true, "heartbeat interval")); return options; }
From source file:org.tolven.appserverproperties.AppServerPropertiesPlugin.java
private Options getCommandOptions() { Options cmdLineOptions = new Options(); OptionGroup optionGroup = new OptionGroup(); Option displayOption = new Option(CMD_LINE_DISPLAY_OPTION, CMD_LINE_DISPLAY_OPTION, false, "\"display server properties\""); optionGroup.addOption(displayOption); Option importOption = new Option(CMD_LINE_LOAD_OPTION, CMD_LINE_LOAD_OPTION, false, "\"load server properties\""); optionGroup.addOption(importOption); Option changeOption = new Option(CMD_LINE_SET_OPTION, CMD_LINE_SET_OPTION, true, "\"set a server property e.g. -set someKey someValue\""); changeOption.setArgs(2); optionGroup.addOption(changeOption); Option removeOption = new Option(CMD_LINE_REMOVE_OPTION, CMD_LINE_REMOVE_OPTION, true, "\"remove a server property e.g. -remove someKey\""); optionGroup.addOption(removeOption); //Option guiOption = new Option(CMD_LINE_GUI_OPTION, CMD_LINE_GUI_OPTION, false, "\"start the password recovery gui\""); //optionGroup.addOption(guiOption); optionGroup.setRequired(true);//from w w w . j a v a2 s . c o m cmdLineOptions.addOptionGroup(optionGroup); return cmdLineOptions; }
From source file:org.tolven.command.TolvenApplication.java
private CommandLine getCommandLine(String[] args) { Options cmdLineOptions = new Options(); Option pluginOption = new Option(CMD_PLUGIN_OPTION, CMD_PLUGIN_OPTION, true, "\"plugin id\""); pluginOption.setRequired(true);//from w ww.j a va 2 s. c o m cmdLineOptions.addOption(pluginOption); OptionGroup optionGroup = new OptionGroup(); Option runtimePluginExistsOption = new Option(CMD_IF_RUNTIME_EXISTS_OPTION, CMD_IF_RUNTIME_EXISTS_OPTION, false, "\"execute if runtime plugin exists\""); optionGroup.addOption(runtimePluginExistsOption); Option noopOption = new Option(CMD_NOOP_OPTION, CMD_NOOP_OPTION, false, "no op plugin starts the plugin framework as a test, but does nothing"); optionGroup.addOption(noopOption); Option formatOption = new Option(CMD_FORMAT_OPTION, CMD_FORMAT_OPTION, false, "formatPluginsFile inputPlugins.xml outputPlugins.xml"); formatOption.setArgs(2); optionGroup.addOption(formatOption); cmdLineOptions.addOptionGroup(optionGroup); try { GnuParser parser = new GnuParser(); CommandLine commandLine = parser.parse(cmdLineOptions, args, true); return commandLine; } catch (ParseException ex) { HelpFormatter formatter = new HelpFormatter(); formatter.printHelp(getClass().getName(), cmdLineOptions); throw new RuntimeException("Could not parse command line for: " + getClass().getName(), ex); } }
From source file:org.tolven.scheduler.SchedulerPlugin.java
private Options getCommandOptions() { Options cmdLineOptions = new Options(); OptionGroup optionGroup = new OptionGroup(); Option startOption = new Option(CMD_LINE_START_OPTION, CMD_LINE_START_OPTION, true, "\"-start schedulerId intervalDuration(ms)\""); startOption.setArgs(2); optionGroup.addOption(startOption);//w w w . ja v a 2 s . c o m Option stopOption = new Option(CMD_LINE_STOP_OPTION, CMD_LINE_STOP_OPTION, true, "\"-stop schedulerId\""); optionGroup.addOption(stopOption); Option statusOption = new Option(CMD_LINE_STATUS_OPTION, CMD_LINE_STATUS_OPTION, true, "\"-status schedulerId\""); optionGroup.addOption(statusOption); optionGroup.setRequired(true); cmdLineOptions.addOptionGroup(optionGroup); return cmdLineOptions; }
From source file:org.tuxedoberries.transformo.app.frontend.CommandLineLauncher.java
public static Options getOptions() { Options options = new Options(); options.addOption("help", "Print this message."); // Generation OptionGroup genGroup = new OptionGroup(); Option tablesOption = new Option("tables", "Generate filled templates by using each table information."); Option fieldsOption = new Option("fields", "Generate filled templates by using each field information."); Option dataOption = new Option("data", "Generate data using a specific format."); genGroup.addOption(tablesOption);//from w ww . j av a 2 s.c om genGroup.addOption(fieldsOption); genGroup.addOption(dataOption); genGroup.setRequired(true); options.addOptionGroup(genGroup); // Database Option database = new Option("d", "Use the given Database. Just XLSX format Supported for now."); database.setArgs(1); database.setArgName("file"); database.setRequired(true); options.addOption(database); // Target Folder Option targetFolder = new Option("tfolder", "Target folder where to save the result."); targetFolder.setArgs(1); targetFolder.setArgName("folder"); options.addOption(targetFolder); // Target File Option targetFile = new Option("tfile", "Target file name expresion. For -tables or -fields can use $file_name$, $field_name$ and/or $field_type$ and any modifiers."); targetFile.setArgs(1); targetFile.setArgName("file"); options.addOption(targetFile); // Target Format OptionGroup formatGroup = new OptionGroup(); Option jsonOption = new Option("json", "[-data only] Generate data using JSON format."); Option shortJsonOption = new Option("sjson", "[-data only] Generate data using Short field name JSON format."); formatGroup.addOption(jsonOption); formatGroup.addOption(shortJsonOption); options.addOptionGroup(formatGroup); // Template Folder Option templateFolder = new Option("sfolder", "[-tables or -fields only] Template source folder. Where to locate all different templates to use."); templateFolder.setArgs(1); templateFolder.setArgName("folder"); options.addOption(templateFolder); // Template File Option templateFile = new Option("sfile", "[-tables or -fields only] Template index source file. The point of origin for the templates."); templateFile.setArgs(1); templateFile.setArgName("file"); options.addOption(templateFile); return options; }
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/*from w w w. j a va 2s .c o m*/ * @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.zend.sdkcli.internal.options.DetectOptionUtility.java
private static void addBoolean(Options options, Method method) { final Option a = method.getAnnotation(Option.class); // create option object final org.apache.commons.cli.Option o = new org.apache.commons.cli.Option(a.opt(), a.description()); if (a.longOpt() != null && a.longOpt().length() > 0) { o.setLongOpt(a.longOpt());// w w w . j a v a 2 s. c o m } o.setArgs(0); o.setRequired(a.required()); // assign to options list options.addOption(o); options.addOption(o); }
From source file:org.zend.sdkcli.internal.options.DetectOptionUtility.java
private static void addString(Options options, Method method) { final Option a = method.getAnnotation(Option.class); // create option object final org.apache.commons.cli.Option o = new org.apache.commons.cli.Option(a.opt(), a.description()); if (a.longOpt() != null && a.longOpt().length() > 0) { o.setLongOpt(a.longOpt());//from w w w .j ava 2 s . c o m } o.setArgs(a.numberOfArgs()); o.setRequired(a.required()); o.setType(a.type()); o.setArgName(a.argName()); // assign to options list options.addOption(o); }
From source file:pl.mcpg.brainfuckjava.Start.java
public static void main(String[] args) { System.out.println("Detected language is " + userLocale.toString() + "."); switch (userLocale.toString()) { case "pl_PL": loadLanguage("pl"); break;/*from w w w . j a v a 2 s . c om*/ default: loadLanguage("en"); break; } Config.load(); try { spacemonoFont = Font.createFont(Font.TRUETYPE_FONT, Start.class.getResourceAsStream("/fonts/spacemono.ttf")); } catch (FontFormatException | IOException e) { e.printStackTrace(); System.exit(1); } if (args.length == 0) // if there are no args, just run GUI. { runGUI(); return; } Options options = new Options(); Option forceLangOption = new Option("l", "forcelang", true, getText("forcelangCli")); forceLangOption.setArgName("language"); Option interactiveOption = new Option("i", "intercml", false, getText("interactiveCli")); Option runOption = new Option("r", "run", true, getText("runCli")); runOption.setArgs(1); Option displayNumbersOption = new Option("n", "displayint", false, getText("dnmCli")); Option helpOption = new Option("h", "help", false, getText("helpCli")); options.addOption(forceLangOption); options.addOption(interactiveOption); options.addOption(runOption); options.addOption(displayNumbersOption); options.addOption(helpOption); CommandLineParser parser = new DefaultParser(); CommandLine commandLine; try { commandLine = parser.parse(options, args); if (commandLine.hasOption('l')) { boolean found = true; switch (commandLine.getOptionValue('l')) { case "pl": loadLanguage("pl"); break; case "en": loadLanguage("en"); break; default: System.err.println(getText("forcedLangNotFound", commandLine.getOptionValue('l'))); found = false; break; } if (found) { System.out.println(getText("forcedLang", commandLine.getOptionValue('l'))); } } if (commandLine.hasOption('h')) { HelpFormatter formatter = new HelpFormatter(); formatter.printHelp("java -jar brainfuck.java.jar [-h] [-n] [-i] [-r {file}]", "Brainfuck.java command line options", options, "Issues? Report them on https://github.com/MCPlayG/Brainfuck.java/issues!"); System.exit(0); } if (commandLine.hasOption('n')) { numberDisplayMode = true; } if (commandLine.hasOption('i')) { new InteractiveCommandLine().run(); System.exit(0); } if (commandLine.hasOption('r')) { run(new File(commandLine.getOptionValue('r'))); System.exit(0); } } catch (ParseException e) { System.err.println(getText("parseCliError")); e.printStackTrace(); runGUI(); } runGUI(); }
From source file:pt.ua.tm.gimli.writer.BCWriter.java
/** * Main program annotate a corpus using one or several models, and save the * result in the BioCreative format./*from w w w .j a v a 2 s . co m*/ * @param args Command line arguments. */ public static void main(String[] args) { // Start stopwatch StopWatch watch = new StopWatch(); watch.start(); CommandLineParser parser = new GnuParser(); Options options = new Options(); options.addOption("h", "help", false, "Print this usage information."); options.addOption("c", "corpus", true, "File with the corpus in the CoNNL format."); Option o = new Option("m", "model", true, MODEL_HELP); o.setArgs(Integer.MAX_VALUE); options.addOption(o); options.addOption("o", "output", true, "File to save the annotated corpus."); CommandLine commandLine = null; try { // Parse the program arguments commandLine = parser.parse(options, args); } catch (ParseException ex) { logger.error("There was a problem processing the input arguments.", ex); return; } // Show help text if (commandLine.hasOption('h')) { printHelp(options, ""); return; } // Get corpus String corpus = null; if (commandLine.hasOption('c')) { corpus = commandLine.getOptionValue('c'); } else { printHelp(options, "Please specify the corpus file."); return; } // Get models String[] input = null; if (commandLine.hasOption('m')) { input = commandLine.getOptionValues('m'); } else { printHelp(options, "Please specify the models."); return; } // Parse models characteristics String[] models = new String[input.length]; String[] features = new String[input.length]; Parsing[] parsing = new Parsing[input.length]; String[] strs; for (int i = 0; i < input.length; i++) { strs = input[i].split(","); if (strs.length != 3) { printHelp(options, "Wrong input format for models."); return; } models[i] = strs[0].trim(); parsing[i] = Parsing.valueOf(strs[1].trim().toUpperCase()); features[i] = strs[2].trim(); } // Get output String output = null; if (commandLine.hasOption('o')) { output = commandLine.getOptionValue('o'); } else { printHelp(options, "Please specify the output file."); return; } // Check length consistency if ((features.length != models.length) || (features.length != parsing.length)) { logger.error( "The number of feature files, parsing, entities and models are different from each other."); return; } // Give user feedback logger.info("Corpus: {}", corpus); logger.info("Models:"); for (int i = 0; i < models.length; i++) { logger.info("\t{}: {}, {}, {}", new Object[] { i + 1, models[i], features[i], parsing[i] }); } logger.info("Output: {}", output); // Load model configurations ModelConfig[] mc = new ModelConfig[features.length]; for (int i = 0; i < features.length; i++) { mc[i] = new ModelConfig(features[i]); } // Load Corpus Corpus c = null; try { c = new Corpus(LabelFormat.BIO, EntityType.protein, corpus); } catch (GimliException ex) { logger.error("There was a problem loading the corpus", ex); return; } // Load models CRFModel[] crfmodels = new CRFModel[models.length]; try { for (int i = 0; i < models.length; i++) { crfmodels[i] = new CRFModel(mc[i], parsing[i], models[i]); } } catch (GimliException ex) { logger.error("There was a problem loading the model(s)", ex); return; } Annotator a = new Annotator(c); if (crfmodels.length > 1) { // Annotate combining the models logger.info("Annotating the corpus by combining {} models... ", crfmodels.length); a.annotate(crfmodels); } else { // Annotate using only one model logger.info("Annotating the corpus using 1 model..."); a.annotate(crfmodels[0]); } // Post-process annotations Parentheses.processRemoving(c); Abbreviation.process(c); // Write to file in the BC format BCWriter writer = new BCWriter(); try { logger.info("Wrtiting annotated corpus into file: {}", output); writer.write(c, output); } catch (GimliException ex) { logger.error("There was a problem writing the corpus to file", ex); } // Time feedback watch.stop(); logger.info("Done!"); logger.info("Total time: {}", watch.toString()); double time = (double) watch.getTime(); double size = (double) c.size(); double perSentence = time / size; double perAbstract = time / (size / 10.0); double perHundred = time / (size / 100.0); logger.info("Per sentence: {} seconds", String.format("%2.4f", perSentence / 1000.0)); logger.info("Per abstract: {} seconds", String.format("%2.4f", perAbstract / 1000.0)); logger.info("10 abstracts: {} seconds", String.format("%2.4f", perHundred / 1000.0)); }