List of usage examples for org.apache.commons.cli OptionBuilder withArgName
public static OptionBuilder withArgName(String name)
From source file:de.clusteval.data.dataset.generator.SpiralsDataSetGenerator.java
@Override protected Options getOptions() { Options options = new Options(); OptionBuilder.withArgName("n"); OptionBuilder.isRequired();/* w ww.j av a 2 s. c om*/ OptionBuilder.hasArg(); OptionBuilder.withDescription("The number of points."); Option option = OptionBuilder.create("n"); options.addOption(option); OptionBuilder.withArgName("c"); OptionBuilder.hasArg(); OptionBuilder.withDescription("The number of cycles."); option = OptionBuilder.create("c"); options.addOption(option); OptionBuilder.withArgName("sd"); OptionBuilder.hasArg(); OptionBuilder.withDescription("The standard deviation."); option = OptionBuilder.create("sd"); options.addOption(option); return options; }
From source file:com.plabadie.mockmail.server.MockMailServer.java
private void initWithCommandLine(String[] args) { Option help = new Option("help", "print this message"); Option port = OptionBuilder.withArgName("portnumber").hasArg() .withDescription("Port number where mockmail serves smtp requests. Default : 2525.").create("port"); Option outdir = OptionBuilder.withArgName("path").hasArg().withDescription( "Folder where the email files will be stored. Can be relative to the working dir. Default : 'mail'") .create("outdir"); Options options = new Options(); options.addOption(help);//from w ww . j a v a2s . co m options.addOption(port); options.addOption(outdir); // create the parser CommandLineParser parser = new GnuParser(); CommandLine line = null; try { // parse the command line arguments line = parser.parse(options, args); } catch (ParseException exp) { // oops, something went wrong System.err.println(exp.getMessage()); System.exit(1); } if (line.hasOption("help")) { // automatically generate the help statement HelpFormatter formatter = new HelpFormatter(); formatter.printHelp("java -jar mockmail.jar", options); System.exit(0); } if (line.hasOption("port")) { String portStringValue = line.getOptionValue("port"); if (StringUtils.isNotBlank(portStringValue) && StringUtils.isNumeric(portStringValue)) { this.setPort(Integer.parseInt(portStringValue)); } } if (line.hasOption("outdir")) { String outDirStringValue = line.getOptionValue("outdir"); if (StringUtils.isNotBlank(outDirStringValue)) { this.setOutDirPath(outDirStringValue); } } }
From source file:de.clusteval.data.dataset.generator.HyperCubeCornersDataSetGenerator.java
@Override protected Options getOptions() { Options options = new Options(); OptionBuilder.withArgName("n"); OptionBuilder.isRequired();//from ww w.ja va 2 s . c om OptionBuilder.hasArg(); OptionBuilder.withDescription("The number of points."); Option option = OptionBuilder.create("n"); options.addOption(option); OptionBuilder.withArgName("d"); OptionBuilder.hasArg(); OptionBuilder.withDescription("The number of dimensions."); option = OptionBuilder.create("d"); options.addOption(option); OptionBuilder.withArgName("sd"); OptionBuilder.hasArg(); OptionBuilder.withDescription("The standard deviation."); option = OptionBuilder.create("sd"); options.addOption(option); return options; }
From source file:edu.umd.cloud9.example.bfs.FindReachableNodes.java
@SuppressWarnings("static-access") @Override// w ww. ja va 2 s . c o m public int run(String[] args) throws Exception { Options options = new Options(); options.addOption( OptionBuilder.withArgName("path").hasArg().withDescription("XML dump file").create(INPUT_OPTION)); options.addOption( OptionBuilder.withArgName("path").hasArg().withDescription("output path").create(OUTPUT_OPTION)); CommandLine cmdline; CommandLineParser parser = new GnuParser(); try { cmdline = parser.parse(options, args); } catch (ParseException exp) { System.err.println("Error parsing command line: " + exp.getMessage()); return -1; } if (!cmdline.hasOption(INPUT_OPTION) || !cmdline.hasOption(OUTPUT_OPTION)) { HelpFormatter formatter = new HelpFormatter(); formatter.printHelp(this.getClass().getName(), options); ToolRunner.printGenericCommandUsage(System.out); return -1; } String inputPath = cmdline.getOptionValue(INPUT_OPTION); String outputPath = cmdline.getOptionValue(OUTPUT_OPTION); LOG.info("Tool name: " + this.getClass().getName()); LOG.info(" - inputDir: " + inputPath); LOG.info(" - outputDir: " + outputPath); Job job = new Job(getConf(), String.format("FindReachableNodes:[%s: %s, %s: %s]", INPUT_OPTION, inputPath, OUTPUT_OPTION, outputPath)); job.setJarByClass(FindReachableNodes.class); job.setNumReduceTasks(0); job.getConfiguration().setInt("mapred.min.split.size", 1024 * 1024 * 1024); FileInputFormat.addInputPath(job, new Path(inputPath)); FileOutputFormat.setOutputPath(job, new Path(outputPath)); job.setInputFormatClass(SequenceFileInputFormat.class); job.setOutputFormatClass(TextOutputFormat.class); job.setMapOutputKeyClass(IntWritable.class); job.setMapOutputValueClass(BFSNode.class); job.setOutputKeyClass(IntWritable.class); job.setOutputValueClass(BFSNode.class); job.setMapperClass(MyMapper.class); // Delete the output directory if it exists already. FileSystem.get(job.getConfiguration()).delete(new Path(outputPath), true); job.waitForCompletion(true); return 0; }
From source file:de.uni_siegen.wineme.come_in.thumbnailer.Main.java
private static void initParams() { options = new Options(); options.addOption(OptionBuilder.withArgName("WIDTHxHEIGHT").hasArg() .withDescription("Size of the new thumbnail (default: 160x120)").create("size")); }
From source file:info.extensiblecatalog.OAIToolkit.importer.CLIProcessor.java
/** * Setup the command line options object * @return the command line options object *//* www . j ava2s . co m*/ public static Options getCommandLineOptions() { Option convert = new Option("convert", "Flag to convert file(s) with raw MARC records into MARCXML"); OptionBuilder.withArgName("modify"); OptionBuilder.hasArg(); OptionBuilder.withDescription("Flag to modify MARCXML file(s) with XSLT transromation with the" + "given XSLT files before loading into the OAI repository"); Option modify = OptionBuilder.create("modify"); Option load = new Option("load", "Flag to load file(s) into the OAI repository"); Option production = new Option("production", "Flag to switch production mode. It means, that the" + "toolkit won't create any temporary files (except error" + " records) so it read MARC records, process it, and put " + "directly to the database or the target file format [DEPRECATED: OPTION IS NO LONGER AVAILABLE]"); OptionBuilder.withArgName("source"); OptionBuilder.hasArg(); OptionBuilder.withDescription("The directory where the toolkit looks " + "for files to process"); Option source = OptionBuilder.create("source"); OptionBuilder.withArgName("destination"); OptionBuilder.hasArg(); OptionBuilder.withDescription("The directory that the toolkit moves the source files into " + "as it successfully completes the processing of each file."); Option destination = OptionBuilder.create("destination"); OptionBuilder.withArgName("destination_xml"); OptionBuilder.hasArg(); OptionBuilder .withDescription("The directory that the toolkit places " + "MARCXML versions of the source data."); Option destination_xml = OptionBuilder.create("destination_xml"); OptionBuilder.withArgName("destination_modifiedxml"); OptionBuilder.hasArg(); OptionBuilder.withDescription( "The directory that the toolkit places " + "modified MARCXML versions of the source data."); Option destination_modifiedxml = OptionBuilder.create("destination_modifiedxml"); OptionBuilder.withArgName("error"); OptionBuilder.hasArg(); OptionBuilder.withDescription("The directory that the toolkit moves files into when " + "there is a processing error for that file."); Option error = OptionBuilder.create("error"); OptionBuilder.hasArg(); OptionBuilder.withArgName("error_xml"); OptionBuilder.withDescription("The directory that the toolkit places MARCXML versions of " + "the source data, if that MARCXML file was unable to be " + "loaded into the OAI repository due to an error condition."); Option error_xml = OptionBuilder.create("error_xml"); OptionBuilder.hasArg(); OptionBuilder.withArgName("error_modifiedxml"); OptionBuilder.withDescription("The directory that the toolkit places MARCXML versions of " + "the source data, if that MARCXML file was unable to be " + "loaded into the OAI repository due to an error condition."); Option error_modifiedxml = OptionBuilder.create("error_modifiedxml"); OptionBuilder.withArgName("log"); OptionBuilder.hasArg(); OptionBuilder.withDescription("The directory of log files for " + "warnings and errors"); Option log = OptionBuilder.create("log"); Option log_detail = new Option("log_detail", "Flag to offer more detailed processing log information"); OptionBuilder.withArgName("marc_schema"); OptionBuilder.hasArg(); OptionBuilder.withDescription("XML Schema file for MARCXML validation"); Option marc_schema = OptionBuilder.create("marc_schema"); OptionBuilder.withArgName("marc_encoding"); OptionBuilder.hasArg(); OptionBuilder.withDescription("The encoding of the MARC file"); Option marc_encoding = OptionBuilder.create("marc_encoding"); OptionBuilder.withArgName("char_conversion"); OptionBuilder.hasArg(); OptionBuilder.withDescription( "The character conversion method. " + "Possible values: MARC8 (Ansel), ISO5426, ISO6937, none"); Option char_conversion = OptionBuilder.create("char_conversion"); OptionBuilder.withArgName("split_size"); OptionBuilder.hasArg(); OptionBuilder.withDescription("How many records can an XML file" + " contain?"); Option split_size = OptionBuilder.create("split_size"); OptionBuilder.withArgName("lucene_index"); OptionBuilder.hasArg(); OptionBuilder.withDescription("Lucene index directory."); Option lucene_index = OptionBuilder.create("lucene_index"); //OptionBuilder.withArgName("storage_type"); //OptionBuilder.hasArg(); //OptionBuilder.withDescription("The storage type of records: MySQL," + //" mixed, Lucene."); //Option storage_type = OptionBuilder.create("storage_type"); Option indent_xml = new Option("indent_xml", "Flag to indent XML"); Option xml_version_11 = new Option("xml_version_11", "Flag to create XML 1.1 instead of 1.0"); Option translate_leader_bad_chars_to_zero = new Option("translate_leader_bad_chars_to_zero", "Change the Bad characters in the leader to zeros"); Option translate_nonleader_bad_chars_to_spaces = new Option("translate_nonleader_bad_chars_to_spaces", "Change the Bad characters in the control and the data fields to spaces"); Option modify_validation = new Option("modify_validation", "Perform validation check during modify step"); OptionBuilder.withArgName("replace_repository_code"); OptionBuilder.hasArg(); OptionBuilder.withDescription("Replace repository code."); Option replace_repository_code = OptionBuilder.create("replace_repository_code"); OptionBuilder.withArgName("convert_dir"); OptionBuilder.hasArg(); OptionBuilder.withDescription("The directory of marc files after " + "process."); Option convert_dir = OptionBuilder.create("convert_dir"); Option fileof_deleted_records = new Option("fileof_deleted_records", "The source marc file should be considered as deleted"); Option lucene_statistics = new Option("lucene_statistics", "Statistics for Lucene Database"); Option lucene_dump_ids = new Option("lucene_dump_ids", "List all ids (001s) to standard output"); OptionBuilder.withArgName("load_dir"); OptionBuilder.hasArg(); OptionBuilder.withDescription("The directory of marcxml files after" + " process."); Option load_dir = OptionBuilder.create("load_dir"); OptionBuilder.withArgName("modify_dir"); OptionBuilder.hasArg(); OptionBuilder.withDescription("The directory of modified marcxml " + "files after process."); Option modify_dir = OptionBuilder.create("modify_dir"); OptionBuilder.withArgName("error_suffix"); OptionBuilder.hasArg(); OptionBuilder.withDescription("The suffix of directory name of error" + " files after process."); Option error_suffix = OptionBuilder.create("error_suffix"); OptionBuilder.withArgName("destination_suffix"); OptionBuilder.hasArg(); OptionBuilder.withDescription("The suffix of directory name of files" + " after process."); Option destination_suffix = OptionBuilder.create("destination_suffix"); OptionBuilder.withArgName("default_repository_code"); OptionBuilder.hasArg(); OptionBuilder.withDescription("The default value of " + "repository code (field 003)."); Option default_repository_code = OptionBuilder.create("default_repository_code"); Option delete = new Option("delete", "Delete temporary files?"); Option ignore_repository_code = new Option("ignore_repository_code", "Do not merge 003 and 001 together."); Option help = new Option("help", "list available options"); Options options = new Options(); options.addOption(production); options.addOption(convert); options.addOption(modify); options.addOption(load); options.addOption(source); options.addOption(destination); options.addOption(destination_xml); options.addOption(error); options.addOption(error_xml); options.addOption(log); options.addOption(log_detail); options.addOption(marc_schema); options.addOption(marc_encoding); options.addOption(char_conversion); options.addOption(split_size); options.addOption(lucene_index); //options.addOption(storage_type); options.addOption(indent_xml); options.addOption(xml_version_11); options.addOption(translate_leader_bad_chars_to_zero); options.addOption(modify_validation); options.addOption(translate_nonleader_bad_chars_to_spaces); options.addOption(fileof_deleted_records); options.addOption(lucene_statistics); options.addOption(lucene_dump_ids); options.addOption(replace_repository_code); options.addOption(convert_dir); options.addOption(load_dir); options.addOption(modify_dir); options.addOption(error_suffix); options.addOption(destination_suffix); options.addOption(delete); options.addOption(destination_modifiedxml); options.addOption(error_modifiedxml); options.addOption(default_repository_code); options.addOption(ignore_repository_code); options.addOption(help); return options; }
From source file:com.google.code.stackexchange.client.examples.AnswersApiExample.java
/** * Builds the options.//from www. j a v a2 s . c o m * * @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 consumerKeyMsg = "You API Key."; OptionBuilder.withArgName("key"); OptionBuilder.hasArg(); OptionBuilder.withDescription(consumerKeyMsg); Option consumerKey = OptionBuilder.create(APPLICATION_KEY_OPTION); opts.addOption(consumerKey); String idMsg = "ID of the users to whom a message is to be sent (separated by comma)."; OptionBuilder.withArgName("id"); OptionBuilder.hasArg(); OptionBuilder.withDescription(idMsg); Option id = OptionBuilder.create(ID_OPTION); opts.addOption(id); return opts; }
From source file:com.flaptor.hounder.indexer.RmiIndexerStub.java
@SuppressWarnings("static-access") private static Options getOptions() { Option host = OptionBuilder.withArgName("hostName").hasArg() .withDescription("the hostname where the indexer is running").isRequired().withLongOpt("host") .create("h"); Option port = OptionBuilder.withArgName("basePort").hasArg() .withDescription("the basePort where the indexer is running").isRequired() .withType(PatternOptionBuilder.NUMBER_VALUE).withLongOpt("port").create("p"); Option delUrl = OptionBuilder.withArgName("url").hasArg().withDescription("a url to delete on the indexer") .withLongOpt("deleteUrl").create("du"); Option delFile = OptionBuilder.withArgName("url-file").hasArg() .withDescription("a file containing urls to delete on the indexer").withLongOpt("deleteFile") .create("df"); Option optimize = new Option("o", "optimize", false, "send optimize command to indexer"); Option checkpoint = new Option("c", "checkpoint", false, "send checkpoint (and push) command to indexer"); Option stop = new Option("s", "stop", false, "send stop command to indexer"); Options options = new Options(); options.addOption(host);/*from ww w.jav a 2s .c o m*/ options.addOption(port); options.addOption(delUrl); options.addOption(delFile); options.addOption(optimize); options.addOption(checkpoint); options.addOption(stop); return options; }
From source file:net.nicholaswilliams.java.licensing.licensor.interfaces.cli.spi.CliOptionsBuilder.java
public CliOptionsBuilder withArgName(String name) { OptionBuilder.withArgName(name); return this; }
From source file:amie.keys.CombinationsExplorationNew.java
/** * Parses the command line arguments and the returns an object that maps * each argument to its value.// w w w . jav a 2s .c o m * * @param args * @return * @throws IOException */ public static CommandLine parseArguments(String[] args) throws IOException { HelpFormatter formatter = new HelpFormatter(); // create the command line parser CommandLineParser parser = new PosixParser(); // create the Options Options options = new Options(); CommandLine cli = null; Option supportOpt = OptionBuilder.withArgName("min-support").hasArg() .withDescription( "Minimum support. Default: 5 positive examples. If the option percentage is enabled, " + "the value is considered as the percentage of entities covered " + "by the a conditional key.") .create("mins"); Option ratioOpt = OptionBuilder.withArgName("percentage") .withDescription("Interpret the support as a percentage " + "Default: false").create("p"); Option nonKeysOpt = OptionBuilder.withArgName("non-keys").withDescription("Path the to the non-keys file.") .hasArg().isRequired().create("nk"); options.addOption(supportOpt); options.addOption(ratioOpt); options.addOption(nonKeysOpt); try { cli = parser.parse(options, args); } catch (ParseException e) { System.out.println("Unexpected exception: " + e.getMessage()); formatter.printHelp("CombinationsExploration [OPTIONS] <TSV FILES>", options); System.exit(1); } String[] fileNameArgs = cli.getArgs(); // Use kb = amie.data.U.loadFiles(args, 1) to ignore the first // argument. This first argument could be the list of non-keys kb = amie.data.U.loadFiles(fileNameArgs); if (cli.hasOption("mins")) { try { support = Integer.parseInt(cli.getOptionValue("mins")); } catch (NumberFormatException e) { System.out.println("Unexpected exception: " + e.getMessage()); formatter.printHelp("CombinationsExploration [OPTIONS] <TSV FILES>", options); System.exit(1); } } if (cli.hasOption("p")) { System.out.println("Support interpreted as a " + support + "% of the number of entities."); long numberOfInstances = kb.size(Column.Subject); System.out.println(numberOfInstances + " instances found as subjects in the KB."); support = (int) Math.ceil(numberOfInstances * support / 100.0); } System.out.println("Using minimum support " + support); return cli; }