public void parse() { cmdFields = new TreeSet<CmdField>(); for (Class c = getClass(); c != null; c = c.getSuperclass()) { for (Field f : c.getDeclaredFields()) { Option o = f.getAnnotation(Option.class); if (o != null) { CmdField cf = new CmdField(); cf.field = f; cf.option = o; cmdFields.add(cf); } } } }
@Option(name = "--analyze-for", usage = "Add a file to analyze for. This " + "can be a plain class file, a jar file, or a directory. Multiple " + "paths can be provided in one string by concatenating them using " + "colons (':'). Empty paths get discarded.") void addAnalyze(final String analyzeFor) { for (final String singleAnalyzeFor : analyzeFor.split(":")) { if (!singleAnalyzeFor.isEmpty()) { final File file = new File(singleAnalyzeFor); if (!file.exists()) { exit("The file '" + file + "' does not exist"); } if (!analyzeFors.add(file)) { exit("Could not add '" + file + "' to analyzes"); } } } }
@Option(name = "--source", usage = "Add a directory to search sources in. " + "Multiple paths can be provided in one string by concatenating them " + "using colons (':'). Empty paths get discarded.") void addSource(final String source) { for (final String singleSource : source.split(":")) { if (!singleSource.isEmpty()) { final File file = new File(singleSource); if (!file.exists()) { exit("The file '" + file + "' does not exist"); } if (!file.isDirectory()) { exit("The file '" + file + "' is not a directory"); } if (!sources.add(file)) { exit("Could not add '" + file + "' to sources"); } } } }
@Option( name = "--limit", aliases = {"-n"}, metaVar = "CNT", usage = "maximum number of users to return" ) public void setLimit(int n) { queryProcessor.setUserProvidedLimit(n); if (n < 0) { suggestLimit = 10; } else if (n == 0) { suggestLimit = MAX_SUGGEST_RESULTS; } else { suggestLimit = Math.min(n, MAX_SUGGEST_RESULTS); } }
@Override public MapperModeOp getOptions() { return new MapperModeOp() { @Option( name = "--threads", aliases = "-j", required = false, usage = "Use NUMBER threads per mapper. defaults n processors.", metaVar = "NUMBER") private int concurrency = Runtime.getRuntime().availableProcessors(); @Override public void prepareJobMapper(Job job, Class<LocalFeaturesMapper> mapperClass) { if (concurrency <= 0) concurrency = Runtime.getRuntime().availableProcessors(); job.setMapperClass(MultithreadedMapper.class); MultithreadedMapper.setNumberOfThreads(job, concurrency); MultithreadedMapper.setMapperClass(job, mapperClass); System.out.println("Using multithreaded mapper"); } }; }
static Type getPlexusCompatibleType(Option option, Field f) { Type fieldType = f.getGenericType(); Class<?> specialCase = TYPE_SPECIAL_CASES.get(option.name()); if (specialCase != null) { return specialCase; } if (fieldType instanceof Class<?>) { Class<?> typeFromClass = getTypeFromClass((Class<?>) fieldType); if (typeFromClass != null) { return typeFromClass; } } if (fieldType instanceof ParameterizedType) { ParameterizedType pt = (ParameterizedType) fieldType; Type rt = pt.getRawType(); if (rt instanceof Class<?> && Collection.class.isAssignableFrom((Class<?>) rt)) { Type[] params = pt.getActualTypeArguments(); if (params.length == 1 && params[0] instanceof Class<?>) { Class<?> elementType = getTypeFromClass((Class<?>) params[0]); if (elementType != null) { return listOfElements(elementType).getType(); } } } } fail("Does not know how to convert " + fieldType + ":" + fieldType.getClass()); return null; }
@Option(name = FLAG_TOOL, aliases = { "-t" }, usage = "target tool and tool params", metaVar = "TOOLNAME TOOLPARAMS", handler = PairStringOptionHandler.class) public void setTool(String[] params) throws CmdLineException { if (params.length != 2) throw new CmdLineException(parser, hystLocalizable, "-tool expected exactly two follow-on arguments: TOOL_NAME TOOL_PARAMS (params can be explicit empty string). See -help_printers."); toolParamsString = params[1]; // look through all the model generators for the right one for (ToolPrinter tp : printers) { String flag = tp.getCommandLineFlag(); if (flag.startsWith("-")) throw new RuntimeException( "tool's command-line flag shouldn't start with a hyphen: " + flag); if (flag.equalsIgnoreCase(params[0])) { toolPrinter = tp; break; } } if (toolPrinter == null) throw new CmdLineException(parser, hystLocalizable, "-tool parameter '" + params[0] + "' was invalid."); }
@Option( name = "--start", aliases = {"-S"}, metaVar = "CNT", usage = "number of plugins to skip" ) public void setStart(int start) { this.start = start; }
@Option( name = "--query", aliases = {"-q"}, metaVar = "QUERY", usage = "match reviewers query" ) public void setQuery(String q) { this.query = q; }
@Option(name = "--httpPort", metaVar = "PORT", usage = "Port for serving HTTP.\nPORT <= 0 will disable this transport.") public Settings httpPort(int port) { this.overrideSetting(Setting.undertow_httpPort, port); return this; }
@Option(name = "--httpListenAddress", metaVar = "ADDRESS", usage = "Interface to use for serving HTTP.") public Settings httpListenAddress(String address) { this.overrideSetting(Setting.undertow_httpListenAddress, address); return this; }
@Option(name = "--httpsPort", metaVar = "PORT", usage = "Port for serving HTTPS.\nPORT <= 0 will disable this transport.") public Settings httpsPort(int port) { this.overrideSetting(Setting.undertow_httpsPort, port); return this; }
@Option(name = "--ajpPort", metaVar = "PORT", usage = "Port for serving AJP.\nPORT <= 0 will disable this transport.") public Settings ajpPort(int port) { this.overrideSetting(Setting.undertow_ajpPort, port); return this; }
@Option(name = "--ajpListenAddress", metaVar = "ADDRESS", usage = "Interface to use for serving AJP.") public Settings ajpListenAddress(String address) { this.overrideSetting(Setting.undertow_ajpListenAddress, address); return this; }
@Option( name = "--source", metaVar = "COMMIT", usage = "the source reference to merge, which could be any git object " + "references expression, refer to " + "org.eclipse.jgit.lib.Repository#resolve(String)", required = true ) public void setSource(String source) { this.source = source; }
/** * Add a group to inspect. * * @param uuid UUID of the group * @deprecated use {@link #addGroup(AccountGroup.UUID)}. */ @Deprecated @Option( name = "--query", aliases = {"-q"}, usage = "group to inspect (deprecated: use --group/-g instead)" ) void addGroup_Deprecated(AccountGroup.UUID uuid) { addGroup(uuid); }
@Option(name = "-lib", usage = "specifies a path to search for jars and classes", metaVar = "<path>") private void setLib(String s) { String[] files = s.split(System.getProperty("path.separator")); for (int i = 0; i < files.length; i++) { lib.add(new File(files[i])); } }
public void printUsage() { System.out.println("Usage: " + this.getName()); for (Field f : this.getClass().getDeclaredFields()) { if (f.isAnnotationPresent(Option.class)) { Option option = f.getAnnotation(Option.class); System.out.println(String.format("\t%-25s %-30s: %s (required=%s)", option.name(), option.metaVar(), option.usage(), option.required())); } } }
@Option( name = "--tree", aliases = {"-t"}, usage = "displays project inheritance in a tree-like format\n" + "this option does not work together with the show-branch option" ) public void setShowTree(boolean showTree) { this.showTree = showTree; }
@Option( name = "--limit", aliases = {"-n"}, metaVar = "CNT", usage = "maximum number of projects to list" ) public void setLimit(int limit) { this.limit = limit; }
@Option( name = "--size", aliases = {"-s"}, usage = "recommended size in pixels, height and width" ) public void setSize(int s) { size = s; }
@Option( name = "--start", aliases = {"-S"}, metaVar = "CNT", usage = "number of groups to skip" ) public void setStart(int start) { this.start = start; }
@Option( name = "--strategy", metaVar = "STRATEGY", usage = "name of the merge strategy, refer to org.eclipse.jgit.merge.MergeStrategy" ) public void setStrategy(String strategy) { this.strategy = strategy; }
@Option( name = "--project", aliases = {"-p"}, usage = "projects for which the groups should be listed" ) public void addProject(ProjectState project) { projects.add(project); }
@Option( name = "--reviewer", aliases = {"-r"}, metaVar = "EMAIL", usage = "add reviewer to changes" ) void reviewer(Account.Id id) { reviewer.add(id); }
@Option(name = "-r", aliases = {"--retain"}, metaVar = "boolean", usage = "Whether suspicious values (i.e. outliers) and inactive points" + " should be kept (optional). By default, they will be removed.") void keepAllPoints(final boolean flag) { this.keepOutliers = flag; this.keepIdlePoints = flag; }
@Option( name = "--match", aliases = {"-m"}, metaVar = "MATCH", usage = "match project substring" ) public void setMatchSubstring(String matchSubstring) { this.matchSubstring = matchSubstring; }
@Option(name = "-v", aliases = {"--verbose"}, metaVar = "boolean", usage = "Increases the amount of information displayed, while the " + "cleaning process runs. By default, only key information " + "is displayed.") void isVerbose(final boolean verbose) { final ch.qos.logback.classic.Logger root = (ch.qos.logback.classic.Logger) LoggerFactory .getLogger(Logger.ROOT_LOGGER_NAME); root.setLevel(ch.qos.logback.classic.Level.DEBUG); final ch.qos.logback.classic.Logger pinetrail = (ch.qos.logback.classic.Logger) LoggerFactory .getLogger("ws.sosna.pinetrail"); pinetrail.setLevel(ch.qos.logback.classic.Level.DEBUG); }
@Override public Object getOptions() { return new ProxyOptionDetails() { @Option( name = "--first-proxy-option", aliases = "-fpo", required = false, usage = "a string", multiValued = true) String firstOption = "first"; }; }
@Option( name = "--limit", aliases = {"-n"}, metaVar = "CNT", usage = "Maximum number of results to return" ) public void setLimit(int limit) { imp.setUserProvidedLimit(limit); }
@Option( name = "--start", aliases = {"-S", "-s"}, metaVar = "CNT", usage = "number of branches to skip" ) public void setStart(int start) { this.start = start; }
/** --query (-q) is already used by {@link ListGroups} */ @Option( name = "--query2", aliases = {"-q2"}, usage = "group query" ) public void setQuery(String query) { this.query = query; }
@Option( name = "--site-path", aliases = {"-d"}, usage = "Local directory containing site data" ) private void setSitePath(String path) { sitePath = Paths.get(path); }
@Option( name = "--has-acl-for", metaVar = "GROUP", usage = "displays only projects on which access rights for this group are directly assigned" ) public void setGroupUuid(AccountGroup.UUID groupUuid) { this.groupUuid = groupUuid; }
@Option( name = "--regex", aliases = {"-r"}, metaVar = "REGEX", usage = "match group regex" ) public void setMatchRegex(String matchRegex) { this.matchRegex = matchRegex; }
@Option( name = "--group", aliases = "-g", metaVar = "GROUP", usage = "initial set of groups to be included in the group" ) void addGroup(AccountGroup.UUID id) { initialGroups.add(id); }
@Option( name = "--query", aliases = {"-q"}, metaVar = "QUERY", usage = "match users" ) public void setQuery(String query) { this.query = query; }
@Option( name = "--suggest", aliases = {"-s"}, usage = "to get a suggestion of groups" ) public void setSuggest(String suggest) { this.suggest = suggest; }
@Option( name = "--regex", aliases = {"-r"}, metaVar = "REGEX", usage = "match branches regex" ) public void setMatchRegex(String matchRegex) { this.matchRegex = matchRegex; }