Java Code Examples for org.apache.commons.cli.Options#addOption()

The following examples show how to use org.apache.commons.cli.Options#addOption() . These examples are extracted from open source projects. 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 Project: mysql_perf_analyzer   File: App.java    License: Apache License 2.0 6 votes vote down vote up
private static Options getAvaliableCommandLineOptions() {
	Options options = new Options();
	options.addOption("f", "config", true, "Configuration file path, no default.");
	options.addOption(
			"j",
			"jettyHome",
			true,
			"Jetty home, if not set, check system property jetty.home, then default to current Dir");
	options.addOption("p", "port", true,
			"http server port, default to 9090.");
	options.addOption("c", "webcontextroot", true,
			"web app url root context, defaul to /");
	options.addOption("l", "logpath", true,
			"log path, default to current directory.");
	options.addOption("w", "warfile", true,
			"war file name, default to myperf.war.");
	options.addOption("k", "workdir", true,
			"work directory for jetty, default to current dir.");
	return options;
}
 
Example 2
/**
 *
 * @return
 */
protected Options createCompareOptions() {
    Options optionsCompare = new Options();
    optionsCompare.addOption("h", "help", false, "Help page for command usage");
    optionsCompare.addOption("u", "premap", false, "use user defined mappings");
    optionsCompare.addOption("Q", "formatQ", true, "Query Type (RXN/SMI)");
    optionsCompare.addOption("q", "query", true, "Query");
    optionsCompare.addOption("T", "formatT", true, "Target Type (RXN/SMI)");
    optionsCompare.addOption("t", "target", true, "Target");
    optionsCompare.addOption("j", "job", true, "Task (COMPARE)");
    optionsCompare.addOption("g", "image", false, "create png of the mapping");
    optionsCompare.addOption("p", "prefix", true, "Job prefix");
    optionsCompare.addOption("f", "formatO", true, "Output format (TEXT/XML/BOTH)");
    optionsCompare.addOption("x", "patterns", false, "Report all matched molecular pairs (RPAIR type)");
    optionsCompare.addOption("c", "complexMode", false, "Use Rings etc. bit time comsuming");
    return optionsCompare;
}
 
Example 3
Source Project: usergrid   File: Repersist.java    License: Apache License 2.0 6 votes vote down vote up
@Override
@SuppressWarnings("static-access")
public Options createOptions() {

    Options options = super.createOptions();

    Option appsOpton = new Option("apps", true,
        "Comma-separated list of apps to re-persisted in {appName}/{orgName} format");
    appsOpton.setRequired(true);
    options.addOption( appsOpton );

    options.addOption("wait", true,
        "Time in milliseconds to  wait between entity re-persist");

    options.addOption("update", false,
        "Tool will update each and every entity in the listed apps");

    return options;
}
 
Example 4
/** Initialze the command. */
public ExtractCommand() {
  Options o = CommandLineHelper.getCommonOptions();
  o.addOption("i", "input", true, "load ontology from a file");
  o.addOption("I", "input-iri", true, "load ontology from an IRI");
  o.addOption("o", "output", true, "save ontology to a file");
  o.addOption("O", "output-iri", true, "set OntologyIRI for output");
  o.addOption("m", "method", true, "extract method to use");
  o.addOption("t", "term", true, "term to extract");
  o.addOption("T", "term-file", true, "load terms from a file");
  o.addOption("u", "upper-term", true, "upper level term to extract");
  o.addOption("U", "upper-terms", true, "upper level terms to extract");
  o.addOption("l", "lower-term", true, "lower level term to extract");
  o.addOption("L", "lower-terms", true, "lower level terms to extract");
  o.addOption("b", "branch-from-term", true, "root term of branch to extract");
  o.addOption("B", "branch-from-terms", true, "root terms of branches to extract");
  o.addOption("c", "copy-ontology-annotations", true, "if true, include ontology annotations");
  o.addOption("f", "force", true, "if true, warn on empty input terms instead of fail");
  o.addOption("a", "annotate-with-source", true, "if true, annotate terms with rdfs:isDefinedBy");
  o.addOption("s", "sources", true, "specify a mapping file of term to source ontology");
  o.addOption("n", "individuals", true, "handle individuals (default: include)");
  o.addOption("M", "imports", true, "handle imports (default: include)");
  o.addOption("N", "intermediates", true, "specify how to handle intermediate entities");
  options = o;
}
 
Example 5
@Override
protected Options getOptions() {
    Options options = new Options();
    options.addOption(OPTION_SRC);
    options.addOption(OPTION_PROJECT);
    options.addOption(OPTION_FORCE_INGEST);
    options.addOption(OPTION_OVERWRITE_TABLES);
    return options;
}
 
Example 6
Source Project: metron   File: ConfigurationManager.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Returns the configurations options that are available.
 * @return The options available
 */
public static Options getOptions() {
  Options ret = new Options();
  for(ConfigurationOptions o : ConfigurationOptions.values()) {
    ret.addOption(o.option);
  }
  return ret;
}
 
Example 7
@Nonnull
protected final CommandLine parseOptions(String optionValue) throws UDFArgumentException {
    String[] args = optionValue.split("\\s+");
    Options opts = getOptions();
    opts.addOption("help", false, "Show function help");
    CommandLine cl = CommandLineUtils.parseOptions(args, opts);

    if (cl.hasOption("help")) {
        Description funcDesc = getClass().getAnnotation(Description.class);
        final String cmdLineSyntax;
        if (funcDesc == null) {
            cmdLineSyntax = getClass().getSimpleName();
        } else {
            String funcName = funcDesc.name();
            cmdLineSyntax = funcName == null ? getClass().getSimpleName()
                    : funcDesc.value().replace("_FUNC_", funcDesc.name());
        }
        StringWriter sw = new StringWriter();
        sw.write('\n');
        PrintWriter pw = new PrintWriter(sw);
        HelpFormatter formatter = new HelpFormatter();
        formatter.printHelp(pw, HelpFormatter.DEFAULT_WIDTH, cmdLineSyntax, null, opts,
            HelpFormatter.DEFAULT_LEFT_PAD, HelpFormatter.DEFAULT_DESC_PAD, null, true);
        pw.flush();
        String helpMsg = sw.toString();
        throw new UDFArgumentException(helpMsg);
    }

    return cl;
}
 
Example 8
/** Initialize the command. */
public UnmergeCommand() {
  Options o = CommandLineHelper.getCommonOptions();
  o.addOption("i", "input", true, "unmerge ontology from a file");
  o.addOption("I", "input-iri", true, "unmerge ontology from an IRI");
  o.addOption("p", "inputs", true, "unmerge ontologies matching wildcard pattern");
  o.addOption("o", "output", true, "save unmerged ontology to a file");
  options = o;
}
 
Example 9
Source Project: kylin   File: SparkCubingByLayer.java    License: Apache License 2.0 5 votes vote down vote up
public SparkCubingByLayer() {
    options = new Options();
    options.addOption(OPTION_INPUT_TABLE);
    options.addOption(OPTION_INPUT_PATH);
    options.addOption(OPTION_CUBE_NAME);
    options.addOption(OPTION_SEGMENT_ID);
    options.addOption(OPTION_META_URL);
    options.addOption(OPTION_OUTPUT_PATH);
}
 
Example 10
@Override
public Options buildCommandlineOptions(Options options) {
    Option opt = new Option("g", "consumerGroup", true, "consumer group name");
    opt.setRequired(true);
    options.addOption(opt);

    return options;
}
 
Example 11
/**
 *
 * @return
 */
protected Options createAnnotateOptions() {
    Options optionsCompare = new Options();
    optionsCompare.addOption("h", "help", false, "Help page for command usage");
    optionsCompare.addOption("Q", "formatQ", true, "Query Type (RXN/SMI)");
    optionsCompare.addOption("q", "query", true, "Query");
    optionsCompare.addOption("j", "job", true, "Task (ANNOTATE)");
    optionsCompare.addOption("u", "premap", false, "use user defined mappings");
    optionsCompare.addOption("g", "image", false, "create png of the mapping");
    optionsCompare.addOption("p", "prefix", true, "Job prefix");
    optionsCompare.addOption("f", "formatO", true, "Output format (TEXT/XML/BOTH)");
    optionsCompare.addOption("x", "patterns", false, "Report all matched molecular pairs (RPAIR type)");
    optionsCompare.addOption("c", "complexMode", false, "Use Rings etc. bit time comsuming");
    return optionsCompare;
}
 
Example 12
Source Project: waltz   File: StorageCli.java    License: Apache License 2.0 5 votes vote down vote up
@Override
protected void configureOptions(Options options) {
    Option storageOption = Option.builder("s")
            .longOpt("storage")
            .desc("Specify storage in format of host:admin_port")
            .hasArg()
            .build();
    Option storagePortOption = Option.builder("sp")
            .longOpt("storage-port")
            .desc("Specify the port of storage, where port is non-admin port")
            .hasArg()
            .build();
    Option partitionOption = Option.builder("p")
            .longOpt("partition")
            .desc("Specify the partition id whose max transaction ID to be returned")
            .hasArg()
            .build();
    Option cliCfgOption = Option.builder("c")
            .longOpt("cli-config-path")
            .desc("Specify the cli config file path required for zooKeeper connection string, zooKeeper root path and SSL config")
            .hasArg()
            .build();
    Option offlineOption = Option.builder("o")
            .longOpt("offline")
            .desc("Check max transaction ID when storage is offline")
            .hasArg(false)
            .build();
    storageOption.setRequired(true);
    storagePortOption.setRequired(true);
    partitionOption.setRequired(true);
    cliCfgOption.setRequired(true);
    offlineOption.setRequired(false);

    options.addOption(storageOption);
    options.addOption(storagePortOption);
    options.addOption(partitionOption);
    options.addOption(cliCfgOption);
    options.addOption(offlineOption);
}
 
Example 13
Source Project: gemfirexd-oss   File: GfxdDdlUtils.java    License: Apache License 2.0 5 votes vote down vote up
protected void addWriteSchemaToSQLOptions(final Options opts) {
  GfxdOption opt;

  FILE_NAME = LocalizedResource.getMessage("TOOLS_FILE");
  opt = new GfxdOptionBuilder().withArgName(LocalizedResource.getMessage(
      "TOOLS_PATH_ARG")).hasArg().isRequired(true).withValueSeparator('=')
      .withDescription(LocalizedResource.getMessage(
          "DDLUTILS_SCHEMA_SQL_OUT_FILE_MESSAGE")).create(FILE_NAME);
  opts.addOption(opt);

  XML_SCHEMA_FILES = LocalizedResource
      .getMessage("DDLUTILS_XML_SCHEMA_FILES");
  opt = new GfxdOptionBuilder().withArgName(LocalizedResource.getMessage(
      "DDLUTILS_PATHS_ARG")).hasArg().withValueSeparator('=')
      .withDescription(LocalizedResource.getMessage(
          "DDLUTILS_XML_SCHEMA_FILES_MESSAGE")).create(XML_SCHEMA_FILES);
  opts.addOption(opt);

  TO_DATABASE_TYPE = LocalizedResource
      .getMessage("DDLUTILS_TO_DATABASE_TYPE");
  opt = new GfxdOptionBuilder().withArgName(LocalizedResource.getMessage(
      "DDLUTILS_TYPE_ARG")).hasArg().withValueSeparator('=')
      .withDescription(LocalizedResource.getMessage(
          "DDLUTILS_TO_DATABASE_TYPE_MESSAGE")).create(TO_DATABASE_TYPE);
  opts.addOption(opt);

  EXPORT_GENERIC = LocalizedResource.getMessage("DDLUTILS_EXPORT_GENERIC");
  opt = new GfxdOptionBuilder().withDescription(LocalizedResource
      .getMessage("DDLUTILS_EXPORT_GENERIC_MESSAGE")).create(EXPORT_GENERIC);
  opts.addOption(opt);

  EXPORT_ALL = LocalizedResource.getMessage("DDLUTILS_EXPORT_ALL");
  opt = new GfxdOptionBuilder().withDescription(LocalizedResource
      .getMessage("DDLUTILS_EXPORT_ALL_MESSAGE")).create(EXPORT_ALL);
  opts.addOption(opt);

  addCommonTaskOptions(opts);
  addCommonReadTaskOptions(opts);
}
 
Example 14
@Override
public Options buildCommandlineOptions(Options options) {
    Option opt = new Option("g", "groupName", true, "consumer group name");
    opt.setRequired(false);
    options.addOption(opt);

    Option optionShowClientIP = new Option("s", "showClientIP", true, "Show Client IP per Queue");
    optionShowClientIP.setRequired(false);
    options.addOption(optionShowClientIP);

    return options;
}
 
Example 15
@NotNull
private static Options createBasicOptions()
{
    final Options options = new Options();
    options.addOption(OUTPUT_DIR, true, "Directory to write Ensembl data files");
    options.addOption(LOG_DEBUG, false, "Log in verbose mode");
    EnsemblDAO.addCmdLineArgs(options);

    return options;
}
 
Example 16
Source Project: Flink-CEPplus   File: CliFrontendParser.java    License: Apache License 2.0 4 votes vote down vote up
private static Options getListOptionsWithoutDeprecatedOptions(Options options) {
	options.addOption(RUNNING_OPTION);
	return options.addOption(SCHEDULED_OPTION);
}
 
Example 17
public static void main(String[] args) throws Exception {
	Options opt = new Options();

	opt.addOption("h", false, "Print help for this application");
	opt.addOption("f", false, "segment file. Default string mode.");
	opt.addOption("s", false, "segment string");
	BasicParser parser = new BasicParser();
	CommandLine cl = parser.parse(opt, args);

	if (args.length == 0 || cl.hasOption('h')) {
		HelpFormatter f = new HelpFormatter();
		f.printHelp(
				"Tagger:\n"
						+ "java edu.fudan.nlp.tag.NERTagger -f segmodel posmodel input_file output_file;\n"
						+ "java edu.fudan.nlp.tag.NERTagger -s segmodel posmodel string_to_segement",
						opt);
		return;
	}
	String[] arg = cl.getArgs();
	String segmodel;
	String posmodel;
	String input;
	String output = null;
	if (cl.hasOption("f") && arg.length == 4) {
		segmodel = arg[0];
		posmodel = arg[1];
		input = arg[2];
		output = arg[3];
	} else if (arg.length == 3) {
		segmodel = arg[0];
		posmodel = arg[1];
		input = arg[2];
	} else {
		System.err.println("paramenters format error!");
		System.err.println("Print option \"-h\" for help.");
		return;
	}
	NERTagger ner = new NERTagger(segmodel,posmodel);
	if (cl.hasOption("f")) {
		ner.tagFile(input,output);
	} else {
		 HashMap<String, String> map = ner.tag(input);
		System.out.println(map);
	}
}
 
Example 18
/**
 * Build and return Options object.
 * 
 * @return Options command line options
 */
private static Options getCmdLineOptions() {
	final Options options = new Options();
	options.addOption("b", true, "path to baseline output");
	return options;
}
 
Example 19
@Override
protected void buildOptions(Options options) {
    options.addOption(null, "threads", true, "number of threads, default 1");
    options.addOption(null, "time", true, "number of secodns to run, default is 10");
}
 
Example 20
Source Project: twister2   File: NomadWorkerStarter.java    License: Apache License 2.0 4 votes vote down vote up
/**
 * Setup the command line options for the MPI process
 *
 * @return cli options
 */
private Options setupOptions() {
  Options options = new Options();

  Option containerClass = Option.builder("c")
      .desc("The class name of the container to launch")
      .longOpt("container_class")
      .hasArgs()
      .argName("container class")
      .required()
      .build();

  Option configDirectory = Option.builder("d")
      .desc("The class name of the container to launch")
      .longOpt("config_dir")
      .hasArgs()
      .argName("configuration directory")
      .required()
      .build();

  Option twister2Home = Option.builder("t")
      .desc("The class name of the container to launch")
      .longOpt("twister2_home")
      .hasArgs()
      .argName("twister2 home")
      .required()
      .build();

  Option clusterType = Option.builder("n")
      .desc("The clustr type")
      .longOpt("cluster_type")
      .hasArgs()
      .argName("cluster type")
      .required()
      .build();

  Option jobID = Option.builder("j")
      .desc("Job id")
      .longOpt("job_id")
      .hasArgs()
      .argName("job id")
      .required()
      .build();
  options.addOption(twister2Home);
  options.addOption(containerClass);
  options.addOption(configDirectory);
  options.addOption(clusterType);
  options.addOption(jobID);

  return options;
}