List of usage examples for org.apache.commons.cli Option setRequired
public void setRequired(boolean required)
From source file:com.opengamma.integration.tool.portfolio.PortfolioZipFormatExamplesGenerator.java
@Override protected Options createOptions(boolean contextProvided) { Options options = super.createOptions(contextProvided); Option filenameOption = new Option(FILE_NAME_OPT, "filename", true, "The path to the file to create and export to (CSV, XLS or ZIP)"); filenameOption.setRequired(true); options.addOption(filenameOption);/* ww w .j a v a 2 s . co m*/ Option writeOption = new Option(WRITE_OPT, "write", false, "Actually persists the portfolio to the file if specified, otherwise pretty-prints without persisting"); options.addOption(writeOption); Option verboseOption = new Option(VERBOSE_OPT, "verbose", false, "Displays progress messages on the terminal"); options.addOption(verboseOption); Option includeTradesOption = new Option(INCLUDE_TRADES_OPT, "trades", false, "Generate a separate row for each trade instead of one row per position"); options.addOption(includeTradesOption); return options; }
From source file:com.axelor.shell.core.Target.java
private Options getOptions() { if (options != null) { return options; }//from ww w .j a v a2s .c o 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; }
From source file:com.soulgalore.crawler.run.AbstractCrawl.java
/** * Get hold of the default options./*from w ww . j av 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:de.mat.utils.pdftools.CmdLineJob.java
/** * <h1>Bereich:</h1>/*from w w w.j a v a 2 s. com*/ * Tools - CLI-Config * <h1>Funktionalitaet:</h1> * konfiguriert die verfuegbaren CLI-Optionen -> sollte ueberladen werden * <h1>Nebenwirkungen:</h1> * Rueckgabe als Options * @return Options * @throws Throwable */ protected Options genAvailiableCmdLineOptions() throws Throwable { Options availiableCmdLineOptions = new Options(); // Hilfe-Option Option helpOption = new Option("h", "help", false, "usage"); helpOption.setRequired(false); availiableCmdLineOptions.addOption(helpOption); return availiableCmdLineOptions; }
From source file:mitm.application.djigzo.tools.Upgrade.java
@SuppressWarnings("static-access") private Options createCommandLineOptions() { Options options = new Options(); Option helpOption = OptionBuilder.withDescription("Show help").create("help"); helpOption.setRequired(false); options.addOption(helpOption);/*from w ww . j a va2 s . com*/ Option versionOption = OptionBuilder.withArgName("version").hasArg().withDescription("version") .create("version"); versionOption.setRequired(true); options.addOption(versionOption); Option userOption = OptionBuilder.withArgName("user").hasArg().withDescription("user").create("user"); userOption.setRequired(false); options.addOption(userOption); Option passwordOption = OptionBuilder.withArgName("password").hasArg().withDescription("password") .create("password"); passwordOption.setRequired(false); options.addOption(passwordOption); hostOption = OptionBuilder.withArgName("host").hasArg() .withDescription("The host to connect to (def: 127.0.0.1)").create("host"); options.addOption(hostOption); portOption = OptionBuilder.withArgName("port").hasArg() .withDescription("The port to use (def: " + DjigzoWSDefaults.PORT + ")").create("port"); options.addOption(portOption); return options; }
From source file:com.opengamma.integration.tool.marketdata.CurveHtsResolverTool.java
@Override protected Options createOptions(final boolean contextProvided) { final Options options = super.createOptions(contextProvided); final Option curveNameOption = new Option(CURVE_NAME_OPT, "name", true, "The name of the yield curve definition for which to resolve time series"); curveNameOption.setRequired(true); options.addOption(curveNameOption);/* ww w . j av a 2 s . c o m*/ final Option writeOption = new Option(WRITE_OPT, "write", false, "Actually persists the time series to the database if specified, otherwise pretty-prints without persisting"); options.addOption(writeOption); final Option verboseOption = new Option(VERBOSE_OPT, "verbose", false, "Displays progress messages on the terminal"); options.addOption(verboseOption); final Option timeSeriesDataProviderOption = new Option(TIME_SERIES_DATAPROVIDER_OPT, "provider", true, "The name of the time series data provider"); options.addOption(timeSeriesDataProviderOption); final Option timeSeriesDataFieldOption = new Option(TIME_SERIES_DATAFIELD_OPT, "field", true, "The name(s) of the time series data field(s)"); options.addOption(timeSeriesDataFieldOption); return options; }
From source file:de.mat.utils.pdftools.PdfMerge.java
@Override protected Options genAvailiableCmdLineOptions() throws Throwable { Options availiableCmdLineOptions = new Options(); // Hilfe-Option Option helpOption = new Option("h", "help", false, "usage"); helpOption.setRequired(false); availiableCmdLineOptions.addOption(helpOption); // Dont Parse List Option file = new Option("f", "filelist", true, "Parse list of pdffiles from tabseaparated file with structure (PDFFILE " + "LABEL TYPE PAGE)" + "\nTYPE and PAGE can be empty" + "\nTYPE is used to style the TOC 'bookmark_line_TYPE' - ue, ue2, master, img are predefined"); file.setRequired(false);//from ww w. jav a 2s . c om availiableCmdLineOptions.addOption(file); // trip empty pages Option flgTrim = new Option("t", "trim", false, "Trim empty pages"); flgTrim.setRequired(false); availiableCmdLineOptions.addOption(flgTrim); return availiableCmdLineOptions; }
From source file:com.soulgalore.crawler.run.CrawlToFile.java
/** * Get the options.//from ww w .j a v a 2 s . c o m * * @return the specific CrawlToCsv options */ @Override protected Options getOptions() { final Options options = super.getOptions(); final Option filenameOption = new Option("f", "the name of the output file, default name is " + DEFAULT_FILENAME + " [optional]"); filenameOption.setArgName("FILENAME"); filenameOption.setLongOpt("filename"); filenameOption.setRequired(false); filenameOption.setArgs(1); options.addOption(filenameOption); final Option errorFilenameOption = new Option("ef", "the name of the error output file, default name is " + DEFAULT_ERROR_FILENAME + " [optional]"); errorFilenameOption.setArgName("ERRORFILENAME"); errorFilenameOption.setLongOpt("errorfilename"); errorFilenameOption.setRequired(false); errorFilenameOption.setArgs(1); options.addOption(errorFilenameOption); final Option verboseOption = new Option("ve", "verbose logging, default is false [optional]"); verboseOption.setArgName("VERBOSE"); verboseOption.setLongOpt("verbose"); verboseOption.setRequired(false); verboseOption.setArgs(1); verboseOption.setType(Boolean.class); options.addOption(verboseOption); return options; }
From source file:eu.scape_project.tool.toolwrapper.component_uploader.ComponentUploader.java
/** Empty constructor */ public ComponentUploader() { // REST client instantiation and configuration restClient = ClientBuilder.newClient(); Option opt; this.options = new Options(); opt = new Option("u", "username", true, "myExperiment username"); opt.setRequired(true); getOptions().addOption(opt);// ww w .j a va 2 s .com opt = new Option("p", "password", true, "myExperiment password"); opt.setRequired(true); getOptions().addOption(opt); opt = new Option("i", "family", true, "component family id"); opt.setRequired(true); getOptions().addOption(opt); opt = new Option("t", "toolspec", true, "toolspec file location"); opt.setRequired(true); options.addOption(opt); opt = new Option("s", "componentspec", true, "component spec file location"); opt.setRequired(true); getOptions().addOption(opt); opt = new Option("c", "component", true, "component file location (Taverna workflow)"); opt.setRequired(true); getOptions().addOption(opt); opt = new Option("l", "license", true, "component license (as myExperiment license set doesn't match the Toolwrapper one)"); opt.setRequired(false); getOptions().addOption(opt); opt = new Option("d", "description", true, "component description"); opt.setRequired(false); getOptions().addOption(opt); opt = new Option("e", "permissions", true, "component permissions (default to private, '--permissions public' for public view/download and '--permissions GROUP_ID' for group GROUP_ID view/download permissions"); opt.setRequired(false); getOptions().addOption(opt); }
From source file:kieker.tools.resourceMonitor.ResourceMonitor.java
@Override protected void addAdditionalOptions(final Options options) { final Option intervalOption = new Option(null, "interval", true, "Sampling interval"); intervalOption.setArgName("interval"); intervalOption.setRequired(false); intervalOption.setArgs(1);//from w w w . java 2 s . c om options.addOption(intervalOption); final Option intervalUnitOption = new Option(null, "interval-unit", true, "Sampling interval time unit (default: SECONDS)"); intervalUnitOption.setArgName("interval-unit"); intervalUnitOption.setRequired(false); intervalUnitOption.setArgs(1); options.addOption(intervalUnitOption); final Option initialDelayOption = new Option(null, "initial-delay", true, "Initial delay"); initialDelayOption.setArgName("initial-delay"); initialDelayOption.setRequired(false); initialDelayOption.setArgs(1); options.addOption(initialDelayOption); final Option durationUnitOption = new Option(null, "initial-delay-unit", true, "Initial delay time unit (default: SECONDS)"); durationUnitOption.setArgName("initial-delay-unit"); durationUnitOption.setRequired(false); durationUnitOption.setArgs(1); options.addOption(durationUnitOption); final Option initialDelayUnitOption = new Option(null, "duration", true, "Monitoring duration"); initialDelayUnitOption.setArgName("duration"); initialDelayUnitOption.setRequired(false); initialDelayUnitOption.setArgs(1); options.addOption(initialDelayUnitOption); final Option durationOption = new Option(null, "duration-unit", true, "Monitoring duration time unit (default: MINUTES)"); durationOption.setArgName("duration-unit"); durationOption.setRequired(false); durationOption.setArgs(1); options.addOption(durationOption); final Option configurationFileOption = new Option("c", CMD_OPT_NAME_MONITORING_CONFIGURATION, true, "Configuration to use for the Kieker monitoring instance"); configurationFileOption.setArgName(OPTION_EXAMPLE_FILE_MONITORING_PROPERTIES); configurationFileOption.setRequired(false); configurationFileOption.setValueSeparator('='); options.addOption(configurationFileOption); }