List of usage examples for org.apache.commons.cli Option setArgs
public void setArgs(int num)
From source file:com.soulgalore.crawler.run.AbstractCrawl.java
/** * Get hold of the default options.//w w w . j av a 2 s. co m * * @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; }//from w w w .jav a 2 s .c om 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.CrawlToFile.java
/** * Get the options./* w w w. ja v a2 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:net.nharyes.drivecopy.Main.java
private void composeOptions() { // file option Option file = OptionBuilder.create('f'); file.setLongOpt("file"); file.setArgs(1); file.setArgName("path"); file.setDescription("where path is the file to upload/download/replace."); // directory option Option directory = OptionBuilder.create('d'); directory.setLongOpt("directory"); directory.setArgs(1);//from w w w. j av a 2 s . c o m directory.setArgName("path"); directory.setDescription( "where path is the local directory to upload/download/replace (it will be archived into a single remote file)."); // file and directory group OptionGroup group = new OptionGroup(); group.addOption(file); group.addOption(directory); group.setRequired(true); options.addOptionGroup(group); // compression level option Option level = OptionBuilder.create('l'); level.setLongOpt("level"); level.setArgs(1); level.setArgName("num"); level.setOptionalArg(true); level.setType(Integer.class); level.setDescription( "where num is the compression level from 0 to 9. Used when uploading/replacing directories. The default value is 0."); options.addOption(level); // delete option Option delete = OptionBuilder.create('D'); delete.setLongOpt("delete"); delete.setOptionalArg(true); delete.setType(Boolean.class); delete.setDescription("delete local file/directory after remote entry uploaded/replaced."); options.addOption(delete); // log option Option log = OptionBuilder.create('L'); log.setLongOpt("log"); log.setArgs(1); log.setArgName("file"); log.setType(String.class); log.setDescription("where file is the log file to write"); options.addOption(log); // MIME type option Option mimeType = OptionBuilder.create('m'); mimeType.setLongOpt("mimetype"); mimeType.setArgs(1); mimeType.setArgName("type"); mimeType.setType(String.class); mimeType.setDescription( "where type is the MIME type string to set for the remote entry. The default values are 'application/octet-stream' for files and 'application/zip' for compressed directories."); options.addOption(mimeType); // skip revision option Option skipRevision = OptionBuilder.create('s'); skipRevision.setLongOpt("skiprevision"); skipRevision.setOptionalArg(true); skipRevision.setType(Boolean.class); skipRevision.setDescription("do not create a new revision when replacing remote entry."); options.addOption(skipRevision); // check MD5 option Option checkMd5 = OptionBuilder.create('c'); checkMd5.setLongOpt("checkmd5"); checkMd5.setOptionalArg(true); checkMd5.setType(Boolean.class); checkMd5.setDescription( "compare uploaded/downloaded local file MD5 summary with the one of the remote entry."); options.addOption(checkMd5); // check force creation option Option forceCreation = OptionBuilder.create('F'); forceCreation.setLongOpt("force"); forceCreation.setOptionalArg(true); forceCreation.setType(Boolean.class); forceCreation.setDescription( "forces the creation of the remote entry when replace is selected and the entry doesn't exist."); options.addOption(forceCreation); // settings file option Option settings = OptionBuilder.create('C'); settings.setLongOpt("configuration"); settings.setArgs(1); settings.setArgName("path"); settings.setType(String.class); settings.setDescription(String.format( "where path is the path of the configuration file. The default value is '%s' in the same directory.", CONFIGURATION_FILE)); options.addOption(settings); // create folders tree option Option tree = OptionBuilder.create('t'); tree.setLongOpt("tree"); tree.setOptionalArg(true); tree.setType(Boolean.class); tree.setDescription("create remote folders tree if one or more remote folders are not found."); options.addOption(tree); }
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);//from ww w .j a v a 2s . c o m intervalOption.setArgs(1); 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); }
From source file:com.zimbra.perf.chart.ChartUtil.java
private static Options getOptions() { Options opts = new Options(); opts.addOption("h", OPT_HELP, false, "prints this usage screen"); Option confOption = new Option("c", OPT_CONF, true, "chart configuration xml files"); confOption.setArgs(Option.UNLIMITED_VALUES); confOption.setRequired(true);/*from w w w .j av a 2 s. c o m*/ opts.addOption(confOption); Option srcDirOption = new Option("s", OPT_SRCDIR, true, "one or more directories where the csv files are located"); srcDirOption.setArgs(Option.UNLIMITED_VALUES); opts.addOption(srcDirOption); Option destDirOption = new Option("d", OPT_DESTDIR, true, "directory where the generated chart files are saved"); opts.addOption(destDirOption); opts.addOption(null, OPT_TITLE, true, "chart title; defaults to last directory name of --" + OPT_SRCDIR + " value"); opts.addOption(null, OPT_START_AT, true, "if specified, ignore all samples before this timestamp (MM/dd/yyyy HH:mm:ss)"); opts.addOption(null, OPT_END_AT, true, "if specified, ignore all samples after this timestamp (MM/dd/yyyy HH:mm:ss)"); opts.addOption(null, OPT_AGGREGATE_START_AT, true, "if specified, aggregate computation starts at this timestamp (MM/dd/yyyy HH:mm:ss)"); opts.addOption(null, OPT_AGGREGATE_END_AT, true, "if specified, aggregate computation ends at this timestamp (MM/dd/yyyy HH:mm:ss)"); opts.addOption(null, OPT_NO_SUMMARY, false, "skip summary data generation"); return opts; }
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 {/* ww w. j a v a2 s . co 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:in.hatimi.nosh.support.CmdLineManager.java
private Option optionFromField(Field field) { CmdLineOption clo = field.getAnnotation(CmdLineOption.class); if (clo == null) { return null; }/*www. j a v a 2 s . com*/ Option option = new Option(clo.name(), clo.description()); //Option option = new Option(clo.name(), clo.longName(), clo.argCount() > 0, clo.description()); if (StringUtils.isNotBlank(clo.longName())) { option.setLongOpt(clo.longName()); } //option.set` option.setArgs(clo.argCount()); option.setRequired(clo.required()); option.setOptionalArg(clo.optionalArg()); option.setValueSeparator(clo.valueSeparator()); return option; }
From source file:de.uni_koblenz.jgralab.utilities.csv2tg.Csv2Tg.java
final protected OptionHandler createOptionHandler() { String toolString = "java " + this.getClass().getName(); String versionString = JGraLab.getInfo(false); OptionHandler oh = new OptionHandler(toolString, versionString); Option schema = new Option("s", CLI_OPTION_SCHEMA, true, "(required): the schema according to which the graph should be constructed."); schema.setRequired(true);/* w ww. j a v a2 s.com*/ schema.setArgName("file"); oh.addOption(schema); Option csvFiles = new Option("i", CLI_OPTION_CSV_FILES, true, "(required): set of csv-file containing vertex / edge instance informations."); csvFiles.setRequired(true); csvFiles.setArgs(Option.UNLIMITED_VALUES); csvFiles.setArgName("files_or_folder"); csvFiles.setValueSeparator(' '); oh.addOption(csvFiles); Option output = new Option("o", CLI_OPTION_OUTPUT_FILE, true, "(required): the output file name, or empty for stdout"); output.setRequired(true); output.setArgName("file"); oh.addOption(output); return oh; }
From source file:net.sourceforge.jencrypt.CommandLineHelper.java
/** * Build the Apache CLI Options collection based on the given string of * short opts.//www . j a v a2 s . c o m * * @param selectOptions * String of first characters of commandline options. * @return */ private Options getOptions(String selectOptions) { Options options = new Options(); Option newOption = null; // Walk through string of short opts and build CLI Options collection for (char s : selectOptions.toCharArray()) { switch (s) { case 'e': newOption = new Option("e", "enc", true, "[File or folder to encrypt] [Destination file]"); newOption.setArgs(3); break; case 'd': newOption = new Option("d", "dec", true, "[File to decrypt] [Destination folder]"); newOption.setArgs(3); break; case 'i': newOption = new Option("i", "ini", false, "[Configuration file]"); newOption.setArgs(1); break; case 'p': newOption = new Option("p", "pwd", false, "[Password to use for en-/decryption]"); newOption.setArgs(1); break; } if (newOption != null) { newOption.setArgName(""); options.addOption(newOption); } } return options; }