org.kohsuke.args4j.Option Java Examples

The following examples show how to use org.kohsuke.args4j.Option. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: CrawlToolOptions.java    From flink-crawler with Apache License 2.0 6 votes vote down vote up
@Option(name = "-agent", usage = "user agent info, format:'name,email,website'", required = false)
public void setUserAgent(String agentNameWebsiteEmailString) {
    if (isCommonCrawl()) {
        throw new RuntimeException("user agent not used in common crawl mode");
    }
    String fields[] = agentNameWebsiteEmailString.split(",", 4);
    if (fields.length != 3) {
        throw new RuntimeException(
                "    Invalid format for user agent (expected 'name,email,website'): "
                        + agentNameWebsiteEmailString);
    }
    String agentName = fields[0];
    String agentEmail = fields[1];
    String agentWebSite = fields[2];
    if (!(agentEmail.contains("@"))) {
        throw new RuntimeException("Invalid email address for user agent: " + agentEmail);
    }
    if (!(agentWebSite.startsWith("http"))) {
        throw new RuntimeException("Invalid web site URL for user agent: " + agentWebSite);
    }
    setUserAgent(new UserAgent(agentName, agentEmail, agentWebSite));
}
 
Example #2
Source File: Flags.java    From js-dossier with Apache License 2.0 6 votes vote down vote up
@Option(
  name = "--strict",
  usage = "Whether to run all type checking passes before generating any documentation"
)
private void setStrict(boolean strict) {
  jsonConfig.addProperty("strict", strict);
}
 
Example #3
Source File: FixCommand.java    From buck with Apache License 2.0 6 votes vote down vote up
private ExitCode runLegacyFixScript(CommandRunnerParams params, ImmutableList<String> scriptPath)
    throws IOException, InterruptedException {
  ProcessExecutor processExecutor =
      new DefaultProcessExecutor(getExecutionContext().getConsole());
  ProcessExecutorParams processParams =
      ProcessExecutorParams.builder()
          .addAllCommand(scriptPath)
          .setEnvironment(params.getEnvironment())
          .setDirectory(params.getCells().getRootCell().getFilesystem().getRootPath().getPath())
          .build();
  int code =
      processExecutor
          .launchAndExecute(
              processParams,
              EnumSet.of(
                  ProcessExecutor.Option.PRINT_STD_ERR, ProcessExecutor.Option.PRINT_STD_OUT),
              Optional.empty(),
              Optional.empty(),
              Optional.empty())
          .getExitCode();
  return ExitCode.map(code);
}
 
Example #4
Source File: AbstractBaseCommand.java    From incubator-pinot with Apache License 2.0 5 votes vote down vote up
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()));
    }
  }
  printExamples();
}
 
Example #5
Source File: Flags.java    From js-dossier with Apache License 2.0 5 votes vote down vote up
@Option(
  name = "--custom_page",
  usage =
      "Defines a markdown file to include with the generated documentation. Each page "
          + "should be defined as $name:$path, where $name is the desired page title and $path "
          + "is the path to the actual file"
)
private void addCustomPage(String spec) {
  List<String> parts = Splitter.on(':').limit(2).splitToList(spec);
  JsonObject page = new JsonObject();
  page.addProperty("name", parts.get(0));
  page.addProperty("path", parts.get(1));
  addToArray("customPages", page);
}
 
Example #6
Source File: KafkaAssignmentGenerator.java    From kafka-assigner with Apache License 2.0 5 votes vote down vote up
private Map<Integer, String> getRackAssignment(ZkUtils zkUtils) {
    List<Broker> brokers = JavaConversions.seqAsJavaList(zkUtils.getAllBrokersInCluster());
    Map<Integer, String> rackAssignment = Maps.newHashMap();
    if (!disableRackAwareness) {
        for (Broker broker : brokers) {
            scala.Option<String> rack = broker.rack();
            if (rack.isDefined()) {
                rackAssignment.put(broker.id(), rack.get());
            }
        }
    }
    return rackAssignment;
}
 
Example #7
Source File: AbstractCommand.java    From buck with Apache License 2.0 5 votes vote down vote up
@Option(
    name = GlobalCliOptions.CONFIG_LONG_ARG,
    aliases = {"-c"},
    usage = "Override .buckconfig option",
    metaVar = "section.option=value")
void addConfigOverride(String configOverride) {
  saveConfigOptionInOverrides(configOverride);
}
 
Example #8
Source File: SampleAnt.java    From codes-scratch-zookeeper-netty with Apache License 2.0 5 votes vote down vote up
@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]));
    }
}
 
Example #9
Source File: Flags.java    From js-dossier with Apache License 2.0 5 votes vote down vote up
@Option(
  name = "--type_filter",
  usage =
      "Regular expression for types that should be excluded from generated documentation,"
          + " even if found in the type graph"
)
private void addTypeFilter(String filter) {
  addToArray("typeFilters", filter);
}
 
Example #10
Source File: Flags.java    From js-dossier with Apache License 2.0 5 votes vote down vote up
@Option(
  name = "--source_url_template",
  usage =
      "Template to use when generating links to source files; refer to --help_json for"
          + " more information."
)
private void setSourceUrlTemplate(String template) {
  jsonConfig.addProperty("sourceUrlTemplate", template);
}
 
Example #11
Source File: AbstractCommand.java    From buck with Apache License 2.0 5 votes vote down vote up
@Option(
    name = GlobalCliOptions.CONFIG_FILE_LONG_ARG,
    usage = "Override options in .buckconfig using a file parameter",
    metaVar = "PATH")
void addConfigFile(String filePath) {
  configOverrides.add(filePath);
}
 
Example #12
Source File: DictionaryToRawIndexConverter.java    From incubator-pinot with Apache License 2.0 5 votes vote down vote up
/**
 * Helper method to print usage at the command line interface.
 */
private static void printUsage() {
  System.out.println("Usage: DictionaryTORawIndexConverter");
  for (Field field : DictionaryToRawIndexConverter.class.getDeclaredFields()) {

    if (field.isAnnotationPresent(Option.class)) {
      Option option = field.getAnnotation(Option.class);

      System.out
          .println(String.format("\t%-15s: %s (required=%s)", option.name(), option.usage(), option.required()));
    }
  }
}
 
Example #13
Source File: Flags.java    From js-dossier with Apache License 2.0 5 votes vote down vote up
@Option(
  name = "--readme",
  metaVar = "PATH",
  usage = "Sets the path to a markdown file to include as a readme on the main landing page"
)
private void setReadme(String path) {
  jsonConfig.addProperty("readme", path);
}
 
Example #14
Source File: Flags.java    From js-dossier with Apache License 2.0 5 votes vote down vote up
@Option(
  name = "--help_json",
  usage = "Print detailed usage information on the JSON configuration file format, then exit"
)
private void setDisplayJsonHelp(boolean help) {
  this.displayJsonHelp = help;
}
 
Example #15
Source File: Flags.java    From js-dossier with Apache License 2.0 5 votes vote down vote up
@Option(
  name = "--config",
  aliases = "-c",
  metaVar = "CONFIG",
  usage =
      "Path to the JSON configuration file to use. If specified, all other configuration "
          + "flags will be ignored"
)
private void setConfigPath(String path) {
  config = fileSystem.getPath(path).toAbsolutePath().normalize();
  checkArgument(Files.exists(config), "Path does not exist: %s", config);
  checkArgument(Files.isReadable(config), "Path is not readable: %s", config);
}
 
Example #16
Source File: Flags.java    From js-dossier with Apache License 2.0 5 votes vote down vote up
@Option(
  name = "--environment",
  metaVar = "ENV",
  usage =
      "Sets the target script environment."
          + " Must be one of {BROWSER, NODE}; defaults to BROWSER"
)
private void setEnvironment(Environment env) {
  jsonConfig.addProperty("environment", env.name());
}
 
Example #17
Source File: Flags.java    From js-dossier with Apache License 2.0 5 votes vote down vote up
@Option(
  name = "--num_threads",
  usage =
      "The number of threads to use for rendering. Defaults to 2 times the number of "
          + "available processors"
)
private void setNumThreads(int n) {
  checkArgument(n >= 1, "invalid number of flags: %s", n);
  this.numThreads = n;
}
 
Example #18
Source File: Flags.java    From js-dossier with Apache License 2.0 5 votes vote down vote up
@Option(
  name = "--closure_library_dir",
  metaVar = "PATH",
  usage =
      "Sets the path to the Closure library's root directory. When provided, Closure files"
          + " will automatically be added as sources based on the goog.require calls in --source"
          + " files. Refer to --help_json for more information"
)
private void setClosureLibraryDir(String path) {
  this.jsonConfig.addProperty("closureLibraryDir", path);
}
 
Example #19
Source File: Flags.java    From js-dossier with Apache License 2.0 5 votes vote down vote up
@Option(
  name = "--closure_dep_file",
  metaVar = "PATH",
  depends = "--closure_library_dir",
  usage =
      "Defines a file to parse for goog.addDependency calls. This requires also providing"
          + " --closure_library_dir"
)
private void addClosureDepFile(String path) {
  addToArray("closureDepFiles", path);
}
 
Example #20
Source File: Flags.java    From js-dossier with Apache License 2.0 5 votes vote down vote up
@Option(
  name = "--source",
  metaVar = "PATH",
  usage =
      "Defines the path to a file to extract API documentation from, or a directory of"
          + " such files"
)
private void addSource(String path) {
  addToArray("sources", path);
}
 
Example #21
Source File: Flags.java    From js-dossier with Apache License 2.0 5 votes vote down vote up
@Option(
  name = "--module",
  metaVar = "PATH",
  usage =
      "Defines the path to a CommonJS module to extract API documentation from, or a"
          + " directory of such files"
)
private void addModule(String path) {
  addToArray("modules", path);
}
 
Example #22
Source File: Flags.java    From js-dossier with Apache License 2.0 5 votes vote down vote up
@Option(
  name = "--extern",
  metaVar = "PATH",
  usage =
      "Defines the path to a file that provides extern definitions, or a directory of"
          + " such files."
)
private void addExtern(String path) {
  addToArray("externs", path);
}
 
Example #23
Source File: Flags.java    From js-dossier with Apache License 2.0 5 votes vote down vote up
@Option(
  name = "--extern_module",
  metaVar = "PATH",
  usage =
      "Defines the path to a file that provides extern definitions for CommonJS modules, "
          + "or a directory of such files."
)
private void addExternModule(String path) {
  addToArray("externModules", path);
}
 
Example #24
Source File: Flags.java    From js-dossier with Apache License 2.0 5 votes vote down vote up
@Option(
  name = "--exclude",
  metaVar = "PATH",
  usage =
      "Defines the path to a file or directory of files that should be excluded from"
          + " processing."
)
private void addExclude(String path) {
  addToArray("excludes", path);
}
 
Example #25
Source File: Flags.java    From js-dossier with Apache License 2.0 5 votes vote down vote up
@Option(
  name = "--output",
  metaVar = "PATH",
  usage = "Sets the path to the output directory, or a .zip file to generate the output in"
)
private void setOutput(String path) {
  jsonConfig.addProperty("output", path);
}
 
Example #26
Source File: N4jscOptions.java    From n4js with Eclipse Public License 1.0 5 votes vote down vote up
/** @return a map that maps all options names to their {@link GoalRequirements}. */
public Map<String, GoalRequirements> getOptionNameToGoalRequirementMap() {
	Map<String, GoalRequirements> nameFieldMap = new HashMap<>();
	Field[] fields = this.options.getClass().getDeclaredFields();
	for (Field field : fields) {
		Option option = field.getDeclaredAnnotation(Option.class);
		GoalRequirements goalRequirements = field.getDeclaredAnnotation(GoalRequirements.class);
		if (field.canAccess(this.options) && option != null && goalRequirements != null) {
			nameFieldMap.put(option.name(), goalRequirements);
		}
	}
	return nameFieldMap;
}
 
Example #27
Source File: Settings.java    From jsonix-schema-compiler with BSD 2-Clause "Simplified" License 4 votes vote down vote up
@Option(name = "-generateJsonSchema", aliases = { "-Xjsonix-generateJsonSchema" })
public void setGenerateJsonSchema(boolean value) {
	generateJsonSchema = value;
}
 
Example #28
Source File: CrawlToolOptions.java    From flink-crawler with Apache License 2.0 4 votes vote down vote up
@Option(name = "-maxoutlinks", usage = "maximum outlinks per page that are extracted", required = false)
public void setMaxOutlinksPerPage(int maxOutlinksPerPage) {
    _maxOutlinksPerPage = maxOutlinksPerPage;
}
 
Example #29
Source File: CrawlToolOptions.java    From flink-crawler with Apache License 2.0 4 votes vote down vote up
@Option(name = "-nolengthen", usage = "Don't do special processing of shortened URLs", required = false)
public void setNoLengthen(boolean noLengthen) {
    _noLengthen = noLengthen;
}
 
Example #30
Source File: Settings.java    From jsonix-schema-compiler with BSD 2-Clause "Simplified" License 4 votes vote down vote up
@Option(name = "-compact", aliases = { "-Xjsonix-compact" })
public void setCompact(boolean value) {
	if (value) {
		defaultNaming = NamingSetting.COMPACT;
	}
}