List of usage examples for org.apache.commons.cli Option setLongOpt
public void setLongOpt(String longOpt)
From source file:com.trackplus.tools.DBConnectionTester.java
private Option newOption(String shortOption, String description, String longOption, String argumentName) { Option option = new Option(shortOption, description); option.setLongOpt(longOption); option.setArgs(1);//from w ww. j ava 2 s . c o m option.setArgName(argumentName); return option; }
From source file:com.spectralogic.autogen.cli.CLI.java
private CLI() { this.options = new Options(); final Option language = new Option("l", true, "Select the language to generate"); final Option directory = new Option("d", true, "Directory to write generated code to"); final Option inputSpec = new Option("i", true, "The spec file for the DS3 API"); final Option help = new Option("h", false, "Print usage"); final Option generateInternal = new Option("internal", false, "Generate Spectra Internal requests"); final Option noDoc = new Option(null, false, "Generate with no documentation"); noDoc.setLongOpt("no-doc"); options.addOption(language);// ww w .java 2 s. co m options.addOption(directory); options.addOption(inputSpec); options.addOption(help); options.addOption(generateInternal); options.addOption(noDoc); }
From source file:com.soulgalore.crawler.run.CrawlToPlainTxtOnlyMatching.java
/** * Get the options./*from w ww . j a va 2s. c o m*/ * * @return the specific CrawlToCsv options */ @Override protected Options getOptions() { final Options options = super.getOptions(); final Option filenameOption = new Option("k", "the keyword to search for in the page [required]"); filenameOption.setArgName("KEYWORD"); filenameOption.setLongOpt("keyword"); filenameOption.setRequired(true); filenameOption.setArgs(1); options.addOption(filenameOption); return options; }
From source file:fr.inrialpes.exmo.align.cli.CommonCLI.java
protected Option createOption(String name, String longName, String desc) { Option opt = new Option(name, desc); opt.setLongOpt(longName); return opt;/*ww w . jav a 2 s. co m*/ }
From source file:com.trackplus.tools.DBConnectionTester.java
private void parseCommandLineArguments(String[] args) { Option option = new Option("h", "Print this help message."); option.setLongOpt("help"); options.addOption(option);// w w w. ja va 2 s .c om option = new Option("v", "Turn on verbose output."); option.setLongOpt("verbose"); options.addOption(option); options.addOption(newOption("u", "Database user name.", "user", "database user")); options.addOption(newOption("c", "JDBC connector class.", "jdbc", "class name")); options.addOption(newOption("url", "Use this user name for login.", "url", "JDBC URL")); options.addOption(newOption("p", "Database user password.", "password", "password")); option.setOptionalArg(true); options.addOption(option); CommandLineParser parser = new GnuParser(); CommandLine line = null; try { line = parser.parse(options, args); } catch (ParseException e) { System.err.println("Error: Parsing failed. Reason: " + e.getMessage()); System.exit(1); } if (line != null) { if (line.hasOption("h")) { printUsage(); System.exit(0); } if (line.hasOption("v")) { verbose = true; } if (line.hasOption("u")) { user = line.getOptionValue("u", ""); } if (line.hasOption("c")) { jdbc = line.getOptionValue("c", ""); } if (line.hasOption("url")) { url = line.getOptionValue("url", ""); } if (line.hasOption("p")) { password = line.getOptionValue("p"); if (password == null) { try { System.out.print("Password: "); System.out.flush(); password = new BufferedReader(new InputStreamReader(System.in)).readLine(); } catch (IOException e) { System.out.println(); System.exit(1); } } } } return; }
From source file:com.spectralogic.ds3contractcomparator.cli.CLI.java
private CLI() { this.options = new Options(); final Option oldSpec = new Option("o", true, "The spec file for the older version of the DS3 API"); final Option newSpec = new Option("n", true, "The spec file for the newer version of the DS3 API"); final Option outFile = new Option("d", true, "The file name for the output of the comparison"); final Option help = new Option("h", false, "Print usage"); final Option properties = new Option(null, false, "Prints EnumConstant Properties which are excluded by default"); properties.setLongOpt("properties"); final Option annotations = new Option(null, false, "Prints all Element Annotations instead of filtering out less used annotations by default"); annotations.setLongOpt("annotations"); final Option printer = new Option("p", true, "Specify report printer: " + PrinterType.valuesString()); options.addOption(oldSpec);/*from ww w . j a v a2s. c o m*/ options.addOption(newSpec); options.addOption(outFile); options.addOption(help); options.addOption(properties); options.addOption(annotations); options.addOption(printer); }
From source file:info.mikaelsvensson.devtools.analysis.shared.CommandLineUtil.java
public List<Option> getOptions(Object owner) throws IllegalAccessException { List<Option> options = new ArrayList<Option>(); Class<?> cls = owner.getClass(); do {/*from w w w . j ava2s . c o m*/ CliOptions cliOptions = cls.getAnnotation(CliOptions.class); if (cliOptions != null) { for (CliOptionConfig config : cliOptions.opts()) { if (config != null) { Option option = new Option(config.name(), config.description()); if (config.longName().length() > 0) { option.setLongOpt(config.longName()); } if (config.numArgs() == OPTIONAL) { option.setOptionalArg(true); } else { option.setArgs(config.numArgs()); } option.setArgName(config.argsDescription()); option.setRequired(config.required()); option.setValueSeparator(config.separator()); options.add(option); } } } } while ((cls = cls.getSuperclass()) != null); return options; }
From source file:com.soulgalore.crawler.run.CrawlToCsv.java
/** * Get the options.// w w w.j a va 2 s . c om * * @return the specific CrawlToCsv options */ @Override protected Options getOptions() { final Options options = super.getOptions(); final Option filenameOption = new Option("f", "the name of the csv output file, default name is " + DEFAULT_FILENAME + " [optional]"); filenameOption.setArgName("FILENAME"); filenameOption.setLongOpt("filename"); filenameOption.setRequired(false); filenameOption.setArgs(1); options.addOption(filenameOption); return options; }
From source file:com.soulgalore.crawler.run.AbstractCrawl.java
/** * Get hold of the default options./*w w w . j a v a 2 s . c om*/ * * @return the options that needs to run a crawl */ @Override protected Options getOptions() { final Options options = super.getOptions(); final Option urlOption = new Option("u", "the page that is the startpoint of the crawl, examle http://mydomain.com/mypage"); urlOption.setLongOpt(URL); urlOption.setArgName("URL"); urlOption.setRequired(true); urlOption.setArgs(1); options.addOption(urlOption); final Option levelOption = new Option("l", "how deep the crawl should be done, default is " + CrawlerConfiguration.DEFAULT_CRAWL_LEVEL + " [optional]"); levelOption.setArgName("LEVEL"); levelOption.setLongOpt(LEVEL); levelOption.setRequired(false); levelOption.setArgs(1); options.addOption(levelOption); final Option followOption = new Option("p", "stay on this path when crawling [optional]"); followOption.setArgName("PATH"); followOption.setLongOpt(FOLLOW_PATH); followOption.setRequired(false); followOption.setArgs(1); options.addOption(followOption); final Option noFollowOption = new Option("np", "no url:s on this path will be crawled [optional]"); noFollowOption.setArgName("NOPATH"); noFollowOption.setLongOpt(NO_FOLLOW_PATH); noFollowOption.setRequired(false); noFollowOption.setArgs(1); options.addOption(noFollowOption); final Option verifyOption = new Option("v", "verify that all links are returning 200, default is set to " + CrawlerConfiguration.DEFAULT_SHOULD_VERIFY_URLS + " [optional]"); verifyOption.setArgName("VERIFY"); verifyOption.setLongOpt(VERIFY); verifyOption.setRequired(false); verifyOption.setArgs(1); options.addOption(verifyOption); final Option requestHeadersOption = new Option("rh", "the request headers by the form of header1:value1@header2:value2 [optional]"); requestHeadersOption.setArgName("REQUEST-HEADERS"); requestHeadersOption.setLongOpt(REQUEST_HEADERS); requestHeadersOption.setRequired(false); requestHeadersOption.setArgs(1); options.addOption(requestHeadersOption); return options; }
From source file:com.axelor.shell.core.Target.java
private Options getOptions() { if (options != null) { return options; }/*w w w .ja v a2 s .co m*/ options = new Options(); int counter = 0; for (CliOption cliOption : cliOptions) { if (cliOption == null) { // variable arguments continue; } Class<?> type = method.getParameterTypes()[counter++]; String name = cliOption.name(); String shortName = "" + cliOption.shortName(); Option option = new Option(shortName, cliOption.help()); option.setType(type); option.setLongOpt(name); option.setRequired(cliOption.required()); option.setArgs(1); if (!isBlank(cliOption.argName())) { option.setArgName(cliOption.argName()); option.setArgs(1); } if (type == boolean.class) { option.setArgs(0); } if (type.isArray()) { option.setArgs(Option.UNLIMITED_VALUES); } options.addOption(option); } return options; }