Java 类org.kohsuke.args4j.Option 实例源码

项目:GemFireLite    文件:CommandBase.java   
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);
      }
    }
  }
}
项目:jacoco-toolbox    文件:ReportTool.java   
@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");
      }
    }
  }
}
项目:jacoco-toolbox    文件:ReportTool.java   
@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");
      }
    }
  }
}
项目:gerrit    文件:QueryAccounts.java   
@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);
  }
}
项目:openimaj    文件:HadoopLocalFeaturesToolOptions.java   
@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");
        }
    };
}
项目:closure-maven-plugin    文件:CheckJsOptionsCompatibleWithCompilerFlagsTest.java   
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;
}
项目:hyst    文件:Hyst.java   
@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.");
}
项目:gerrit    文件:ListPlugins.java   
@Option(
  name = "--start",
  aliases = {"-S"},
  metaVar = "CNT",
  usage = "number of plugins to skip"
)
public void setStart(int start) {
  this.start = start;
}
项目:gerrit    文件:SuggestReviewers.java   
@Option(
  name = "--query",
  aliases = {"-q"},
  metaVar = "QUERY",
  usage = "match reviewers query"
)
public void setQuery(String q) {
  this.query = q;
}
项目:fathom    文件:Settings.java   
@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;
}
项目:fathom    文件:Settings.java   
@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;
}
项目:fathom    文件:Settings.java   
@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;
}
项目:fathom    文件:Settings.java   
@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;
}
项目:fathom    文件:Settings.java   
@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;
}
项目:gerrit    文件:CheckMergeability.java   
@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;
}
项目:gerrit    文件:ListGroups.java   
/**
 * 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);
}
项目:scratch_zookeeper_netty    文件:SampleAnt.java   
@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]));
    }
}
项目:Pinot    文件:AbstractBaseCommand.java   
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()));
    }
  }
}
项目:gerrit    文件:ListProjects.java   
@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;
}
项目:gerrit    文件:QueryProjects.java   
@Option(
  name = "--limit",
  aliases = {"-n"},
  metaVar = "CNT",
  usage = "maximum number of projects to list"
)
public void setLimit(int limit) {
  this.limit = limit;
}
项目:gerrit    文件:GetAvatar.java   
@Option(
  name = "--size",
  aliases = {"-s"},
  usage = "recommended size in pixels, height and width"
)
public void setSize(int s) {
  size = s;
}
项目:gerrit    文件:ListGroups.java   
@Option(
  name = "--start",
  aliases = {"-S"},
  metaVar = "CNT",
  usage = "number of groups to skip"
)
public void setStart(int start) {
  this.start = start;
}
项目:gerrit    文件:CheckMergeability.java   
@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;
}
项目:gerrit    文件:ListGroups.java   
@Option(
  name = "--project",
  aliases = {"-p"},
  usage = "projects for which the groups should be listed"
)
public void addProject(ProjectState project) {
  projects.add(project);
}
项目:gerrit    文件:ReceiveCommits.java   
@Option(
  name = "--reviewer",
  aliases = {"-r"},
  metaVar = "EMAIL",
  usage = "add reviewer to changes"
)
void reviewer(Account.Id id) {
  reviewer.add(id);
}
项目:pinetrail    文件:Cleaner.java   
@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;
}
项目:gerrit    文件:ListProjects.java   
@Option(
  name = "--match",
  aliases = {"-m"},
  metaVar = "MATCH",
  usage = "match project substring"
)
public void setMatchSubstring(String matchSubstring) {
  this.matchSubstring = matchSubstring;
}
项目:pinetrail    文件:Cleaner.java   
@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);
}
项目:openimaj    文件:TestArgsUtil.java   
@Override
public Object getOptions() {
    return new ProxyOptionDetails() {
        @Option(
                name = "--first-proxy-option",
                aliases = "-fpo",
                required = false,
                usage = "a string",
                multiValued = true)
        String firstOption = "first";
    };
}
项目:gerrit    文件:QueryChanges.java   
@Option(
  name = "--limit",
  aliases = {"-n"},
  metaVar = "CNT",
  usage = "Maximum number of results to return"
)
public void setLimit(int limit) {
  imp.setUserProvidedLimit(limit);
}
项目:gerrit    文件:ListBranches.java   
@Option(
  name = "--start",
  aliases = {"-S", "-s"},
  metaVar = "CNT",
  usage = "number of branches to skip"
)
public void setStart(int start) {
  this.start = start;
}
项目:gerrit    文件:QueryGroups.java   
/** --query (-q) is already used by {@link ListGroups} */
@Option(
  name = "--query2",
  aliases = {"-q2"},
  usage = "group query"
)
public void setQuery(String query) {
  this.query = query;
}
项目:gerrit    文件:QueryGroups.java   
@Option(
  name = "--start",
  aliases = {"-S"},
  metaVar = "CNT",
  usage = "number of groups to skip"
)
public void setStart(int start) {
  this.start = start;
}
项目:gerrit    文件:SiteProgram.java   
@Option(
  name = "--site-path",
  aliases = {"-d"},
  usage = "Local directory containing site data"
)
private void setSitePath(String path) {
  sitePath = Paths.get(path);
}
项目:gerrit    文件:ListProjects.java   
@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;
}
项目:gerrit    文件:ListGroups.java   
@Option(
  name = "--regex",
  aliases = {"-r"},
  metaVar = "REGEX",
  usage = "match group regex"
)
public void setMatchRegex(String matchRegex) {
  this.matchRegex = matchRegex;
}
项目:gerrit    文件:CreateGroupCommand.java   
@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);
}
项目:gerrit    文件:QueryAccounts.java   
@Option(
  name = "--query",
  aliases = {"-q"},
  metaVar = "QUERY",
  usage = "match users"
)
public void setQuery(String query) {
  this.query = query;
}
项目:gerrit    文件:ListGroups.java   
@Option(
  name = "--suggest",
  aliases = {"-s"},
  usage = "to get a suggestion of groups"
)
public void setSuggest(String suggest) {
  this.suggest = suggest;
}
项目:gerrit    文件:ListBranches.java   
@Option(
  name = "--regex",
  aliases = {"-r"},
  metaVar = "REGEX",
  usage = "match branches regex"
)
public void setMatchRegex(String matchRegex) {
  this.matchRegex = matchRegex;
}