List of usage examples for org.apache.commons.cli OptionBuilder withLongOpt
public static OptionBuilder withLongOpt(String newLongopt)
From source file:com.tvh.gmaildrafter.Drafter.java
private static Options getCMDLineOptions() { /*//from ww w . j a v a2s. c o m * Create the command line options */ Options options = new Options(); options.addOption(new Option("h", "help", false, "Show this help message.")); OptionGroup body = new OptionGroup(); body.addOption(new Option("i", "stdin", false, "Read body text from stdin.")); body.addOption(OptionBuilder.withLongOpt("body").withArgName("filename").hasArg() .withDescription("File containing the body text").create("b")); options.addOptionGroup(body); options.addOption(OptionBuilder.withLongOpt("username").hasArg().withArgName("email address") .withDescription("Your Google Email adress.").create()); options.addOption(OptionBuilder.withLongOpt("password").hasArg().withArgName("google password") .withDescription( "Your Google password (caution: providing this on the commandline can be a security problem).") .create()); options.addOption(OptionBuilder.withLongOpt("subject").withArgName("text").hasArg() .withDescription("Subject of the mail").create("s")); options.addOption(OptionBuilder.withLongOpt("subjectfile").withArgName("filename").hasArg() .withDescription("File containing the subject of the mail (UTF-8)").create()); options.addOption(OptionBuilder.withLongOpt("attachments").hasArgs().withArgName("filename,filename,...") .withValueSeparator(',').withDescription("Attachments").create("a")); options.addOption( OptionBuilder.withLongOpt("attachmentnames").hasArgs().withArgName("filename,filename,...") .withValueSeparator(',').withDescription("Attachment names").create("n")); options.addOption(OptionBuilder.withLongOpt("to").hasArgs().withArgName("foo@bar.com,oof@rab.com,...") .withValueSeparator(',').withDescription("destination").create("t")); options.addOption(new Option("d", "deletebody", false, "Delete bodyfile after sending.")); options.addOption(new Option(null, "deletesubjectfile", false, "Delete subjectfile after sending.")); options.addOption(new Option(null, "immediate", false, "Immediately send, don't open draft first.")); options.addOption(OptionBuilder.withLongOpt("cc").hasArgs().withArgName("foo@bar1.com,foo@rba.com") .withValueSeparator(',').withDescription("cc").create("c")); options.addOption(OptionBuilder.withLongOpt("bcc").hasArgs().withArgName("foo@bar2.com,ofo@bar.com") .withValueSeparator(',').withDescription("bcc").create()); return options; }
From source file:benchmark.hbase.controller.TestLauncher.java
@SuppressWarnings("static-access") private static Options initializeOptions() { final Options options = new Options(); options.addOption("u", "usage", false, "show usage"); // Required options options.addOption(OptionBuilder.withLongOpt("store-type") .withDescription("store type => HBASE | CASSANDRA | MONGODB").isRequired().hasArg().create()); options.addOption(/*from w w w . j a v a2 s .co m*/ OptionBuilder.withLongOpt("num-reads").withDescription("number of reads").hasArg().create()); options.addOption( OptionBuilder.withLongOpt("num-writes").withDescription("number of writes").hasArg().create()); options.addOption(OptionBuilder.withLongOpt("read-concurrancy").withDescription("Read concurrancy") .isRequired().hasArg().create()); options.addOption(OptionBuilder.withLongOpt("write-concurrancy").withDescription("Write concurrancy") .isRequired().hasArg().create()); // Optional options options.addOption(OptionBuilder.withLongOpt("benchmark-type").withDescription( "benchmark type, one of READ_ONLY | WRITE_ONLY | READ_AND_WRITE. Will default to READ_ONLY, if not specified.") .hasArg().create()); options.addOption( OptionBuilder.withLongOpt("connection-url").withDescription("connection url").hasArg().create()); return options; }
From source file:de.uniulm.omi.cloudiator.visor.config.CommandLinePropertiesAccessorImpl.java
private void generateOptions(Options options) { options.addOption(OptionBuilder.withLongOpt("localIp").withDescription("IP of the local machine").hasArg() .create("ip")); options.addOption(OptionBuilder.withLongOpt("configFile").withDescription("Configuration file location.") .isRequired().hasArg().create("conf")); }
From source file:cc.redpen.Main.java
@SuppressWarnings("static-access") public static int run(String... args) throws RedPenException { Options options = new Options(); options.addOption("h", "help", false, "Displays this help information and exits"); options.addOption(OptionBuilder.withLongOpt("format") .withDescription("Input file format (markdown,plain,wiki,asciidoc,latex,rest)").hasArg() .withArgName("FORMAT").create("f")); options.addOption(OptionBuilder.withLongOpt("conf").withDescription("Configuration file (REQUIRED)") .hasArg().withArgName("CONF FILE").create("c")); options.addOption(OptionBuilder.withLongOpt("result-format") .withDescription("Output result format (json,json2,plain,plain2,xml)").hasArg() .withArgName("RESULT FORMAT").create("r")); options.addOption(OptionBuilder.withLongOpt("limit").withDescription("Error limit number").hasArg() .withArgName("LIMIT NUMBER").create("l")); options.addOption(OptionBuilder.withLongOpt("sentence").withDescription("Input sentences").hasArg() .withArgName("INPUT SENTENCES").create("s")); options.addOption(OptionBuilder.withLongOpt("lang").withDescription("Language of error messages").hasArg() .withArgName("LANGUAGE").create("L")); options.addOption(OptionBuilder.withLongOpt("threshold") .withDescription("Threshold of error level (info, warn, error)").hasArg().withArgName("THRESHOLD") .create("t")); options.addOption(OptionBuilder.withLongOpt("version") .withDescription("Displays version information and exits").create("v")); CommandLineParser commandLineParser = new BasicParser(); CommandLine commandLine;//from ww w .j a v a2s . c o m try { commandLine = commandLineParser.parse(options, args); } catch (ParseException e) { LOG.error("Error occurred in parsing command line options "); printHelp(options); return -1; } String inputFormat = "plain"; String configFileName = null; String resultFormat = "plain"; String inputSentence = null; String language = "en"; String threshold = "error"; int limit = DEFAULT_LIMIT; if (commandLine.hasOption("h")) { printHelp(options); return 0; } if (commandLine.hasOption("v")) { System.out.println(RedPen.VERSION); return 0; } if (commandLine.hasOption("f")) { inputFormat = commandLine.getOptionValue("f"); } if (commandLine.hasOption("c")) { configFileName = commandLine.getOptionValue("c"); } if (commandLine.hasOption("r")) { resultFormat = commandLine.getOptionValue("r"); } if (commandLine.hasOption("l")) { limit = Integer.valueOf(commandLine.getOptionValue("l")); } if (commandLine.hasOption("L")) { language = commandLine.getOptionValue("L"); } if (commandLine.hasOption("s")) { inputSentence = commandLine.getOptionValue("s"); } if (commandLine.hasOption("t")) { threshold = commandLine.getOptionValue("t"); } // set language if (language.equals("ja")) { Locale.setDefault(new Locale("ja", "JA")); } else { Locale.setDefault(new Locale("en", "EN")); } String[] inputFileNames = commandLine.getArgs(); if (!commandLine.hasOption("f")) { inputFormat = guessInputFormat(inputFileNames); } File configFile = resolveConfigLocation(configFileName); if (configFile == null) { LOG.error("Configuration file is not found."); printHelp(options); return 1; } if (inputFileNames.length == 0 && inputSentence == null) { LOG.error("Input is not given"); printHelp(options); return 1; } RedPen redPen; try { redPen = new RedPen(configFile); } catch (RedPenException e) { LOG.error("Failed to parse input files: " + e); return -1; } List<Document> documents = getDocuments(inputFormat, inputSentence, inputFileNames, redPen); Map<Document, List<ValidationError>> documentListMap = redPen.validate(documents, threshold); Formatter formatter = FormatterUtils.getFormatterByName(resultFormat); if (formatter == null) { LOG.error("Unsupported format: " + resultFormat + " - please use xml, plain, plain2, json or json2"); return -1; } String result = formatter.format(documentListMap); System.out.println(result); long errorCount = documentListMap.values().stream().mapToLong(List::size).sum(); if (errorCount > limit) { LOG.error("The number of errors \"{}\" is larger than specified (limit is \"{}\").", errorCount, limit); return 1; } else { return 0; } }
From source file:iDynoOptimizer.MOEAFramework26.src.org.moeaframework.analysis.sensitivity.ResultFileInfo.java
@SuppressWarnings("static-access") @Override//from w w w.j av a 2 s . c om public Options getOptions() { Options options = super.getOptions(); OptionGroup group = new OptionGroup(); group.setRequired(true); group.addOption(OptionBuilder.withLongOpt("problem").hasArg().withArgName("name").create('b')); group.addOption(OptionBuilder.withLongOpt("dimension").hasArg().withArgName("number").create('d')); options.addOptionGroup(group); options.addOption(OptionBuilder.withLongOpt("output").hasArg().withArgName("file").create('o')); return options; }
From source file:jmxsh.Main.java
private Options makeCommandLineOptions() { Options opts = new Options(); opts.addOption(OptionBuilder.withLongOpt("server").withDescription("JMX Service URL of remote JMX service.") .withArgName("SERVER").hasArg().create("s")); opts.addOption(//ww w .j av a2 s. c om OptionBuilder.withLongOpt("host").withDescription("Hostname or IP address of remote JMX service.") .withArgName("HOST").hasArg().create("h")); opts.addOption(OptionBuilder.withLongOpt("port").withDescription("Port of remote JMX service.") .withArgName("PORT").hasArg().create("p")); opts.addOption(OptionBuilder.withLongOpt("url_path").withDescription("Path portion of the JMX Service URL.") .withArgName("PATH").hasArg().create("T")); opts.addOption(OptionBuilder.withLongOpt("user").withArgName("USER").hasArg() .withDescription("Connect with this username.").create("U")); opts.addOption(OptionBuilder.withLongOpt("password").withArgName("PASSWORD").hasArg() .withDescription("Connect with this password.").create("P")); opts.addOption( OptionBuilder.withLongOpt("debug").withDescription("Verbose logging.").hasArg(false).create("d")); opts.addOption(OptionBuilder.withLongOpt("logfile").withDescription("Log information to this file.") .withArgName("LOGFILE").hasArg().create("l")); opts.addOption(OptionBuilder.withLongOpt("version").hasArg(false) .withDescription("Show version information.").create("v")); opts.addOption( OptionBuilder.withLongOpt("help").withDescription("Display usage help.").hasArg(false).create("?")); opts.addOption(OptionBuilder.withLongOpt("protocol") .withDescription("Choose a connection protocol (rmi|jmxmp), default rmi.").hasArg(true) .withArgName("PROTOCOL").create("R")); opts.addOption(OptionBuilder.withLongOpt("include").withDescription( "Source this file. May be specified multiple times. [N.B. Do not make this the last option, because of a bug in CLI parsing library.]") .withArgName("FILE").hasArg().hasArgs().create("i")); opts.addOption(OptionBuilder.withLongOpt("interactive") .withDescription("Always go into interactive mode, even if executing a script.").hasArg(false) .create("I")); opts.addOption(OptionBuilder.withLongOpt("browse") .withDescription("Start interactive session in browser mode.").hasArg(false).create("b")); opts.addOption(OptionBuilder.withLongOpt("nohistory").withDescription("Do not save history.").hasArg(false) .create("n")); opts.addOption(OptionBuilder.withLongOpt("historyfile") .withDescription("Use this file to save history (default $HOME/.jmxsh_history).").hasArg(true) .withArgName("HISTORYFILE").create("H")); return opts; }
From source file:cognition.pipeline.commandline.CommandCreateModeFromFile.java
@Override public void addOption(Options options) { options.addOption(OptionBuilder.withLongOpt("createMode") .withDescription("Application processes all records from scratch.").withArgName("createMode") .create());//from www . ja va2 s. com options.addOption(OptionBuilder.withLongOpt("file").withDescription("Json file to process").hasOptionalArg() .withArgName("file").create()); }
From source file:iDynoOptimizer.MOEAFramework26.src.org.moeaframework.analysis.sensitivity.SetHypervolume.java
@SuppressWarnings("static-access") @Override/*from w w w. ja v a 2 s . co m*/ public Options getOptions() { Options options = super.getOptions(); options.addOption(OptionBuilder.withLongOpt("epsilon").hasArg().withArgName("e1,e2,...").create('e')); return options; }
From source file:de.tudarmstadt.lt.lm.app.StartRMI.java
@SuppressWarnings("static-access") public StartRMI(String[] args) { LOG.warn("This main is only for convencience and might be deprectated soon. Consider using {}.", StartLM.class.getName()); Options opts = new Options(); opts.addOption(OptionBuilder.withLongOpt("help").withDescription("Display help message.").create("?")); opts.addOption(OptionBuilder.withLongOpt("port").withArgName("port-number").hasArg().withDescription(String .format("specifies the port on which rmi registry listens (default: %d)", Registry.REGISTRY_PORT)) .create("p")); try {/* w w w . ja v a 2 s . co m*/ CommandLine cmd = new ExtendedGnuParser(true).parse(opts, args); if (cmd.hasOption("help")) CliUtils.print_usage_quit(System.err, StartLM.class.getSimpleName(), opts, USAGE_HEADER, null, 0); _port = Integer.parseInt(cmd.getOptionValue("port", String.valueOf(Registry.REGISTRY_PORT))); } catch (Exception e) { LOG.error("{}: {}", e.getClass().getSimpleName(), e.getMessage()); CliUtils.print_usage_quit(System.err, StartLM.class.getSimpleName(), opts, USAGE_HEADER, String.format("%s: %s%n", e.getClass().getSimpleName(), e.getMessage()), 1); } }
From source file:gr.evoltrio.conf.CliParametersParser.java
private void addOptions() { OptionBuilder.withLongOpt("begDur").withDescription("Sets the duration of the first note in a phrase") .hasArg().withArgName("[1,6]"); // music parameters options.addOption(OptionBuilder.create()); options.addOption(OptionBuilder.withLongOpt("phraseNotes") .withDescription("Sets the number of notes a phrase will contain").hasArg().withArgName("[4,32]") .create());/*from www . ja v a2 s.c om*/ options.addOption(OptionBuilder.withLongOpt("intJump") .withDescription("Sets the max interval jump between two adjacent notes").hasArg() .withArgName("[1,12]").create()); options.addOption(OptionBuilder.withLongOpt("durJump") .withDescription("Sets the max duration jump between two adjacent notes").hasArg() .withArgName("[1,6]").create()); options.addOption(OptionBuilder.withLongOpt("note").withDescription("The pitch of the key note").hasArg() .withArgName("[ C | C# | .. | B ]").create()); options.addOption(OptionBuilder.withLongOpt("octave").withDescription("The octave of the key note").hasArg() .withArgName("[2,7]").create()); options.addOption(OptionBuilder.withLongOpt("pattern").withDescription("The music pattern to use").hasArg() .withArgName("[ I-IV-V-I ]").create()); options.addOption(OptionBuilder.withLongOpt("drums").withDescription("The drum pattern to use").hasArg() .withArgName("[ default ]").create()); options.addOption(OptionBuilder.withLongOpt("bass").withDescription("The bass pattern to use").hasArg() .withArgName("[ default ]").create()); options.addOption(OptionBuilder.withLongOpt("tempo").withDescription("Defines the music tempo").hasArg() .withArgName("[ ADAGIO ]").create()); options.addOption(OptionBuilder.withLongOpt("organ") .withDescription("The midi instrument that the solist is going to use").hasArg() .withArgName("[0,127]").create()); // parameters for the evolution options.addOption(OptionBuilder.withLongOpt("random").withDescription("The random generator to use") .hasArg().withArgName("[ STOCK | CAUCHY | GAUSSIAN ]").create()); options.addOption(OptionBuilder.withLongOpt("natural").withDescription("The natural selector to use") .hasArg().withArgName("[ BEST | THRESHOLD | TOURNAMENT | WEIGHTED ]").create()); options.addOption("u", "execBefore", false, "Execute the natural selector before the genetic operators"); options.addOption(OptionBuilder.withLongOpt("minpop") .withDescription("Minimum percent size guaranteed for population").hasArg().withArgName("[0,100]") .create()); options.addOption(OptionBuilder.withLongOpt("previousGen") .withDescription( "Defines the percentage of the chromosomes that are going to enter the new population") .hasArg().withArgName("[0,1]").create()); options.addOption("f", "constant", false, "Keep constant the population size"); options.addOption(OptionBuilder.withLongOpt("crossover").withDescription("Defines the crossover rate") .hasArg().withArgName("[0,1]").create()); options.addOption(OptionBuilder.withLongOpt("mutation").withDescription("Defines the mutation rate") .hasArg().withArgName("[0,100]").create()); options.addOption(OptionBuilder.withLongOpt("pop").withDescription("Defines the population size").hasArg() .withArgName("[0,1000]").create()); options.addOption(OptionBuilder.withLongOpt("iterations") .withDescription("Sets the number of iterations that each phrase will evolve").hasArg() .withArgName("[1,10000]").create()); // fitness parameters options.addOption("1", "filtall", false, "Enables all the fitness filters. This option will override any other made that involves filters"); options.addOption("P", "pitch", false, "Enables simple pitch fitness filter"); options.addOption("D", "duration", false, "Enables simple duration fitness filter"); options.addOption("S", "scale", false, "Enables scale notes fitness filter. USE THIS!"); options.addOption("T", "time", false, "Enables time fitness filter"); options.addOption("B", "dull", false, "Enables dull (boring music) fitness filter"); options.addOption("H", "high", false, "Enables high diversity of notes fitness filter"); options.addOption("R", "repetition1", false, "Enables repetition of notes fitness filter"); options.addOption("E", "repetition2", false, "Enables a different repetition of notes fitness filter"); options.addOption("A", "ascending", false, "Enables adjacent ascending notes fitness filter"); options.addOption("Z", "descending", false, "Enables adjacent descending notes fitness filter"); // options.addOption(OptionBuilder.withLongOpt("file").isRequired() // .withDescription("The file to store the produced midi") // .hasArg().withArgName("FILE").create()); options.addOption("v", "version", false, "Show version"); options.addOption("h", "help", false, "Print this screen and quit"); }