List of usage examples for org.apache.commons.cli OptionBuilder withArgName
public static OptionBuilder withArgName(String name)
From source file:jlite.cli.ProxyDelegate.java
private static Options setupOptions() { Options options = new Options(); options.addOption(OptionBuilder.withDescription("displays usage").create("help")); options.addOption(OptionBuilder.withArgName("id_string") .withDescription("delegation id (default is user name)").hasArg().create("d")); options.addOption(OptionBuilder.withArgName("service_URL").withDescription("WMProxy service endpoint") .hasArg().create("e")); options.addOption(OptionBuilder.withArgName("proxyfile") .withDescription("non-standard location of proxy cert").hasArg().create("proxypath")); options.addOption(OptionBuilder.withArgName("xml").withDescription("output as xml").create("xml")); return options; }
From source file:it.infodreams.syncpath.commands.Commander.java
public Commander() { Option help = new Option("help", "Print this help message"); Option verbose = new Option("verbose", "Show more output information during process"); Option version = new Option("version", "Show the version information"); Option scan = OptionBuilder.withLongOpt("scan") .withDescription("Attempts full scan of a specified path and creates a report").create("c"); Option pack = OptionBuilder.withLongOpt("pack").withDescription("Perform a packing process").create("p"); Option unpack = OptionBuilder.withLongOpt("unpack").withDescription("Perform a packing process") .create("u"); Option sourcePath = OptionBuilder.withArgName("path").hasArg() .withDescription("Path to use as source for operations.").withLongOpt("source-path").create("s"); Option destPath = OptionBuilder.withArgName("path").hasArg() .withDescription("Path to use as destionation for operations.").withLongOpt("dest-path") .create("d"); Option reportFile = OptionBuilder.withArgName("filename").hasArg() .withDescription("Report to use as source for packing operations.").withLongOpt("report") .create("r"); Option splitSize = OptionBuilder.withArgName("size-in-bytes").hasArg() .withDescription("Size of each splitted package (0 for unlimited size).").withLongOpt("split-size") .create("t"); options.addOption(help);//from w ww. j a v a 2s.co m options.addOption(verbose); options.addOption(version); options.addOption(scan); options.addOption(sourcePath); options.addOption(destPath); options.addOption(reportFile); options.addOption(pack); options.addOption(splitSize); options.addOption(unpack); }
From source file:com.dobrunov.zktreeutil.zkTreeUtilMain.java
public static Options initOptions() { Options options = new Options(); options.addOption("e", "export", false, "exports the zookeeper tree"); Option outdir = OptionBuilder.withArgName("dir").hasArg().withDescription( "output directory to which znode information should be written (must be a normal, empty directory)") .create("od"); outdir.setLongOpt("output-dir"); options.addOption(outdir);//from w ww . j a v a2 s. co m Option plainfile = OptionBuilder.withArgName("filename").hasArg() .withDescription("output file to which znode information should be written").create("of"); plainfile.setLongOpt("output-file"); options.addOption(plainfile); Option xmlfile = OptionBuilder.withArgName("filename").hasArg() .withDescription("output xml-file to which znode information should be written").create("ox"); xmlfile.setLongOpt("output-xmlfile"); options.addOption(xmlfile); Option znodepath = OptionBuilder.withArgName("znodepath").hasArg() .withDescription("path to the zookeeper subtree rootnode.").create("p"); znodepath.setLongOpt("path"); options.addOption(znodepath); Option server = OptionBuilder.withArgName("zkhosts").hasArg().isRequired(true) .withDescription("zookeeper remote servers (ie \"localhost:2181\")").create("z"); server.setLongOpt("zookeeper"); options.addOption(server); return options; }
From source file:ape.CorruptCommand.java
/** * The constructor for this command simply creates its Option object (used by * the CLI parser)//from w w w . j a va 2s . co m */ public CorruptCommand() { option = OptionBuilder.withArgName("meta/ord> <size> <offset").hasArgs(3).withValueSeparator() .withDescription( "Corrupt a random HDFS block file with a size in bytes as the 2nd arg and offset in bytes as the 3rd argument") .withLongOpt("corrupt-block").create("C"); }
From source file:com.yahoo.semsearch.fastlinking.io.Datapack.java
@Override @SuppressWarnings("static-access") public int run(String[] args) throws Exception { Options options = new Options(); options.addOption(//ww w. j a v a 2s. c om OptionBuilder.withArgName("path").hasArg().withDescription("output").create(OUTPUT_OPTION)); options.addOption(OptionBuilder.withArgName("path").hasArg().withDescription("multi-output") .create(MULTI_OUTPUT_OPTION)); options.addOption(OptionBuilder.withArgName("path").hasArg().withDescription("output for anchor map") .create(ANCHORMAP_OPTION)); options.addOption(OptionBuilder.withArgName("path").hasArg().withDescription("output for anchor cf map") .create(CFMAP_OPTION)); options.addOption(OptionBuilder.withArgName("ngram").hasArg().withDescription("chunk into ngram") .create(NGRAM_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(OUTPUT_OPTION) || !cmdline.hasOption(ANCHORMAP_OPTION) || !cmdline.hasOption(CFMAP_OPTION)) { HelpFormatter formatter = new HelpFormatter(); formatter.printHelp(this.getClass().getName(), options); ToolRunner.printGenericCommandUsage(System.out); return -1; } merge(cmdline.getOptionValue(ANCHORMAP_OPTION), cmdline.getOptionValue(CFMAP_OPTION), cmdline.getOptionValue(MULTI_OUTPUT_OPTION), cmdline.getOptionValue(OUTPUT_OPTION), cmdline.getOptionValue(NGRAM_OPTION)); return 0; }
From source file:jlite.cli.JobCancel.java
private static Options setupOptions() { Options options = new Options(); options.addOption(OptionBuilder.withDescription("displays usage").create("help")); options.addOption(OptionBuilder.withArgName("file_path") .withDescription("select JobId(s) from the specified file").hasArg().create("i")); options.addOption(OptionBuilder.withArgName("service_URL").withDescription("WMProxy service endpoint") .hasArg().create("e")); options.addOption(OptionBuilder.withArgName("proxyfile") .withDescription("non-standard location of proxy cert").hasArg().create("proxypath")); options.addOption(OptionBuilder.withArgName("xml").withDescription("output as xml").create("xml")); return options; }
From source file:com.indeed.imhotep.index.builder.util.EasyIndexBuilderOptions.java
@Override protected void setup() { description = "builds index shard for specified time range\n" + "start and end must be in yyyy-MM-dd HH:mm:ss format, but mins and secs will be truncated.\n" + "DO quote start and end"; examples = "-o /var/ramses/tmp/indexname -r odin:9091 --start \"2009-06-16 09:00:00\" --end \"2009-06-16 12:00:00\""; options.addOption(OptionBuilder.isRequired().withArgName("YYYY-MM-DD HH:MM:SS") .withDescription("start time for processing, can be milliseconds").hasArg().withLongOpt("start") .create());//from w ww . j a v a 2 s .c om options.addOption(OptionBuilder.isRequired().withArgName("YYYY-MM-DD HH:MM:SS") .withDescription("end time for processing, can be milliseconds").hasArg().withLongOpt("end") .create()); options.addOption(OptionBuilder.isRequired().withArgName("dir").withDescription("output directory").hasArg() .withLongOpt("output").create("o")); options.addOption(OptionBuilder.withArgName("args").withDescription("additional arguments").hasArg() .withLongOpt("extra").create("e")); options.addOption( OptionBuilder.withDescription("clear this segment if it exists").withLongOpt("overwrite").create()); options.addOption( OptionBuilder.withDescription("exit without error if logs exist").withLongOpt("skip").create()); }
From source file:eu.riscoss.dataproviders.Main.java
public static void exec_single(String[] args) { Options options = new Options(); /* These two options are mandatory for the Risk Data Collector */ Option rdr = OptionBuilder.withArgName("url").hasArg().withDescription("Risk Data Repository URL") .create("rdr"); // Option entity = OptionBuilder.withArgName("entityId").hasArg().withDescription("Entity ID (OSS name)").create("entity"); Option entity = OptionBuilder.withArgName("properties").hasArg() .withDescription("Properties File (with component-related config)").create("properties"); options.addOption(rdr);// w ww .j av a 2s.c o m options.addOption(entity); /* Print help if no arguments are specified. */ if (args.length == 0) { HelpFormatter formatter = new HelpFormatter(); formatter.printHelp("rdc-template", options); System.exit(1); } /* Parse the command line */ CommandLineParser parser = new GnuParser(); CommandLine cmd; try { cmd = parser.parse(options, args); String riskDataRepositoryURL = cmd.getOptionValue("rdr"); if (riskDataRepositoryURL == null) { System.err.format("Risk data repository not specified."); System.exit(1); } // the name of the OSS to analyse String propertiesFile = cmd.getOptionValue("properties"); if (propertiesFile == null) { System.err.format("Properties file not specified."); System.exit(1); } /* Initialisation here, will be passed by parameters or config file */ // targetEntity = "XWiki"; //(should be parameter) if (writeProperties) //creates a new, hard-coded config properties = RdpConfig.loadWrite(propertiesFile); else { //read the default config file Properties defaultProperties = RdpConfig.loadDefaults(defaultPropertiesFile); //read the config from file properties = RdpConfig.load(propertiesFile, defaultProperties); } String targetEntity = properties.getProperty("targetEntity"); System.out.println(); System.out.println("************************************************"); System.out.printf("Starting the analysis for component %s.\n\n", targetEntity); IndicatorsMap im = new IndicatorsMap(targetEntity); /* Risk Data collector main logic called here */ DataProviderManager.init(im, properties); DataProviderManager.register(1, new FossologyDataProvider()); DataProviderManager.register(2, new MavenLicensesProvider()); DataProviderManager.register(3, new MarkmailDataProvider()); DataProviderManager.register(4, new JiraDataProvider()); DataProviderManager.register(5, new SonarDataProvider()); DataProviderManager.register(0, new ManualDataProvider()); // DataProviderManager.execAll(); DataProviderManager.exec(1); // DataProviderManager.exec(3); System.out.println("\n**** Resulting indicators ****" + im.entrySet()); System.out.flush(); /******************************************************/ /* * At the end, send the result to the Risk Data Repository * Example repository: http://riscoss-platform.devxwiki.com/rdr/xwiki?limit=10000 */ if (sendResults) { //put all the indicators into the riskData List List<RiskData> riskData = new ArrayList<RiskData>(); /* This list should be generated by the Risk Data Collector logic :) */ riskData.addAll(im.values()); //riskData.add(RiskDataFactory.createRiskData("iop", targetEntity, new Date(), RiskDataType.NUMBER, 1.0)); try { RDR.sendRiskData(riskDataRepositoryURL, riskData); System.out .println("\nIndicators sent via REST to " + riskDataRepositoryURL + "/" + targetEntity); } catch (Exception e) { System.err.print("Warning: Not able to send inicators via REST to " + riskDataRepositoryURL); e.printStackTrace(); //System.err.println(" Exception: "+e.getClass().getName()); } } if (csvresults) { System.out.println("Results in CSV format retrieved " + new Date()); for (String key : im.keySet()) { RiskData content = im.get(key); // if (content.getType().equals(RiskDataType.DISTRIBUTION) System.out.print("# " + content.getTarget() + "\t" + content.getId() + "\t"); switch (content.getType()) { case DISTRIBUTION: for (Double d : ((Distribution) content.getValue()).getValues()) System.out.print(d + "\t"); break; case NUMBER: System.out.print(content.getValue()); break; default: break; } System.out.print("\n"); } System.out.println("CSV End"); } } catch (ParseException e1) { System.err.println("Error in parsing command line arguments. Exiting."); e1.printStackTrace(); System.exit(1); } }
From source file:jlite.cli.JobOutput.java
private static Options setupOptions() { Options options = new Options(); options.addOption(OptionBuilder.withDescription("displays usage").create("help")); options.addOption(OptionBuilder.withArgName("file_path") .withDescription("select JobId(s) from the specified file").hasArg().create("i")); options.addOption(OptionBuilder.withArgName("service_URL").withDescription("WMProxy service endpoint") .hasArg().create("e")); options.addOption(OptionBuilder.withArgName("dir_path") .withDescription("store output files in the specified directory (default is CURRENT_DIR/JOB_ID)") .hasArg().create("dir")); options.addOption(//from www .j av a 2s . c o m OptionBuilder.withDescription("do not purge job output after retrieval").create("nopurge")); options.addOption(OptionBuilder.withDescription("do not retrieve output files, just print their URIs") .create("list")); options.addOption(OptionBuilder.withArgName("proxyfile") .withDescription("non-standard location of proxy cert").hasArg().create("proxypath")); options.addOption(OptionBuilder.withArgName("xml").withDescription("output as xml").create("xml")); // options.addOption(OptionBuilder // .withArgName("protocol") // .withDescription("protocol to be used for file tranfer {gsiftp,https} (default is gsiftp)") // .hasArg() // .create("proto")); return options; }
From source file:com.dm.estore.server.CommandLineOptions.java
private Option createOption(final String argument, final String description, final String option) { OptionBuilder.withArgName(argument); OptionBuilder.hasArg();/*from w w w. ja v a2 s. co m*/ OptionBuilder.withDescription(description); return OptionBuilder.create(option); }