Example usage for org.apache.commons.cli OptionGroup setRequired

List of usage examples for org.apache.commons.cli OptionGroup setRequired

Introduction

In this page you can find the example usage for org.apache.commons.cli OptionGroup setRequired.

Prototype

public void setRequired(boolean required) 

Source Link

Usage

From source file:org.apache.kylin.job.CubeMetaExtractor.java

public CubeMetaExtractor() {
    options = new Options();

    OptionGroup realizationOrProject = new OptionGroup();
    realizationOrProject.addOption(OPTION_CUBE);
    realizationOrProject.addOption(OPTION_PROJECT);
    realizationOrProject.addOption(OPTION_HYBRID);
    realizationOrProject.setRequired(true);

    options.addOptionGroup(realizationOrProject);
    options.addOption(OPTION_INCLUDE_SEGMENTS);
    options.addOption(OPTION_INCLUDE_JOB);
    options.addOption(OPTION_DEST);/*from  w ww  .  ja v  a2s.  co m*/

}

From source file:org.apache.kylin.tool.CubeMetaExtractor.java

public CubeMetaExtractor() {
    super();//from www . j av a2  s.c om

    packageType = "cubemeta";

    OptionGroup realizationOrProject = new OptionGroup();
    realizationOrProject.addOption(OPTION_CUBE);
    realizationOrProject.addOption(OPTION_PROJECT);
    realizationOrProject.addOption(OPTION_HYBRID);
    realizationOrProject.addOption(OPTION_All_PROJECT);
    realizationOrProject.setRequired(true);

    options.addOptionGroup(realizationOrProject);
    options.addOption(OPTION_INCLUDE_SEGMENTS);
    options.addOption(OPTION_INCLUDE_JOB);
    options.addOption(OPTION_INCLUDE_SEGMENT_DETAILS);
    options.addOption(OPTION_INCLUDE_ONLY_JOB_OUTPUT);
    options.addOption(OPTION_STORAGE_TYPE);
    options.addOption(OPTION_ENGINE_TYPE);
}

From source file:org.apache.kylin.tool.HBaseUsageExtractor.java

public HBaseUsageExtractor() {
    super();//www .  jav a  2s .co  m
    packageType = "hbase";

    OptionGroup realizationOrProject = new OptionGroup();
    realizationOrProject.addOption(OPTION_CUBE);
    realizationOrProject.addOption(OPTION_PROJECT);
    realizationOrProject.setRequired(true);

    options.addOptionGroup(realizationOrProject);
    conf = HBaseConfiguration.create();
}

From source file:org.apache.marmotta.ldpath.backend.file.FileQuery.java

@SuppressWarnings("static-access")
private static Options buildOptions() {
    Options result = new Options();

    OptionGroup input = new OptionGroup();
    Option file = OptionBuilder.withArgName("file").hasArg().withDescription("query the contents of a file")
            .create("file");
    Option url = OptionBuilder.withArgName("url").hasArg().withDescription("query the contents of a remote URL")
            .create("url");

    input.addOption(file);//from   w ww.j  av a2 s. com
    input.addOption(url);
    input.setRequired(true);

    result.addOptionGroup(input);

    Option format = OptionBuilder.withArgName("mimetype").hasArg()
            .withDescription("MIME type of the input document").create("format");
    result.addOption(format);

    OptionGroup query = new OptionGroup();
    Option path = OptionBuilder.withArgName("path").hasArg()
            .withDescription("LD Path to evaluate on the file starting from the context").create("path");
    Option program = OptionBuilder.withArgName("file").hasArg()
            .withDescription("LD Path program to evaluate on the file starting from the context")
            .create("program");
    query.addOption(path);
    query.addOption(program);
    query.setRequired(true);
    result.addOptionGroup(query);

    Option context = OptionBuilder.withArgName("uri").hasArg()
            .withDescription("URI of the context node to start from").create("context");
    context.setRequired(true);
    result.addOption(context);

    Option loglevel = OptionBuilder.withArgName("level").hasArg()
            .withDescription("set the log level; default is 'warn'").create("loglevel");
    result.addOption(loglevel);

    return result;
}

From source file:org.apache.marmotta.ldpath.backend.linkeddata.LDQuery.java

@SuppressWarnings("static-access")
private static Options buildOptions() {
    Options result = new Options();

    OptionGroup query = new OptionGroup();
    Option path = OptionBuilder.withArgName("path").hasArg()
            .withDescription("LD Path to evaluate on the file starting from the context").create("path");
    Option program = OptionBuilder.withArgName("file").hasArg()
            .withDescription("LD Path program to evaluate on the file starting from the context")
            .create("program");
    query.addOption(path);//from  ww w.  j  ava  2s . c o m
    query.addOption(program);
    query.setRequired(true);
    result.addOptionGroup(query);

    Option context = OptionBuilder.withArgName("uri").hasArg()
            .withDescription("URI of the context node to start from").create("context");
    context.setRequired(true);
    result.addOption(context);

    Option loglevel = OptionBuilder.withArgName("level").hasArg()
            .withDescription("set the log level; default is 'warn'").create("loglevel");
    result.addOption(loglevel);

    Option store = OptionBuilder.withArgName("dir").hasArg()
            .withDescription("cache the retrieved data in this directory").create("store");
    result.addOption(store);

    return result;
}

From source file:org.apache.marmotta.ldpath.ldquery.LDQuery.java

@SuppressWarnings("static-access")
private static Options buildOptions() {
    Options result = new Options();

    OptionGroup query = new OptionGroup();
    Option path = OptionBuilder.withArgName("path").hasArg()
            .withDescription("LD Path to evaluate on the file starting from the context").create("path");
    Option program = OptionBuilder.withArgName("file").hasArg()
            .withDescription("LD Path program to evaluate on the file starting from the context")
            .create("program");
    query.addOption(path);//w  w w  . j a v  a2s .co m
    query.addOption(program);
    query.setRequired(true);
    result.addOptionGroup(query);

    Option context = OptionBuilder.withArgName("uri").hasArg()
            .withDescription("URI of the context node to start from").create("context");
    context.setRequired(true);
    result.addOption(context);

    Option loglevel = OptionBuilder.withArgName("level").hasArg()
            .withDescription("set the log level; default is 'warn'").create("loglevel");
    result.addOption(loglevel);

    Option store = OptionBuilder.withArgName("dir").hasArg()
            .withDescription("cache the retrieved data in this directory").create("store");
    result.addOption(store);

    Option format = OptionBuilder.withArgName("format").hasArg().withDescription("output format")
            .create("format");
    result.addOption(format);

    return result;
}

From source file:org.apache.marmotta.loader.core.MarmottaLoader.java

/**
 * Build command line options. Base options are:
 * <ul>/*from  ww w  .  ja v  a 2 s.  c om*/
 *     <li>-h | --help: show help</li>
 *     <li>-B | --backend: backend to use (kiwi, hbase, berkeleydb)</li>
 *     <li>-z | --gzip: input is GZIP encoded</li>
 *     <li>-j | --bzip2: input is BZIP2 encoded</li>
 *     <li>-c | --context: URI of a context to add the statement to</li>
 *     <li>-b | --base: URI to use as base for resolving relative URIs</li>
 *     <li>-f | --file: input file to use for loading</li>
 *     <li>-d | --dir:  input directory containing files to use for loading</li>
 *     <li>-t | --type: input format to use for parsing (MIME type)</li>
 *     <li>-s | --statistics: collect statistics and write a graph into the file given</li>
 * </ul>
 *
 * In addition, loader backends can provide their own additional command line options.
 *
 * @return
 */
private static Options buildOptions() {
    final Options options = new Options();

    options.addOption("h", "help", false, "print this help");

    OptionGroup compression = new OptionGroup();
    compression.addOption(new Option("z", "gzip", false, "input is gzip compressed"));
    compression.addOption(new Option("j", "bzip2", false, "input is bzip2 compressed"));
    options.addOptionGroup(compression);

    final Option backend = OptionBuilder.withArgName("backend").hasArgs(1)
            .withDescription("backend to use ("
                    + StringUtils.join(
                            Iterators.transform(backends.iterator(), new BackendIdentifierFunction()), ", ")
                    + ")")
            .withLongOpt("backend").create('B');
    options.addOption(backend);

    final Option base = OptionBuilder.withArgName("base").hasArgs(1)
            .withDescription("base URI to use for resolving relative URIs").withLongOpt("base").create('b');
    options.addOption(base);

    final Option context = OptionBuilder.withArgName("context").hasArgs(1)
            .withDescription("URI of a context to add the statement to").withLongOpt("context").create('c');
    options.addOption(context);

    final Option format = OptionBuilder.withArgName("type").hasArgs(1)
            .withDescription("input format to use for parsing (MIME type) in case auto-guessing does not work")
            .withLongOpt("type").create('t');
    options.addOption(format);

    // input options
    OptionGroup input = new OptionGroup();
    input.setRequired(true);
    final Option file = OptionBuilder.withArgName("file").hasArgs(Option.UNLIMITED_VALUES)
            .withDescription("input file(s) to load").withLongOpt("file").create('f');
    input.addOption(file);

    final Option directories = OptionBuilder.withArgName("dir").hasArgs(Option.UNLIMITED_VALUES)
            .withDescription("input directories(s) to load").withLongOpt("dir").create('d');
    input.addOption(directories);

    final Option archives = OptionBuilder.withArgName("archive").hasArgs(Option.UNLIMITED_VALUES)
            .withDescription("input archives(s) to load (zip, tar.gz)").withLongOpt("archive").create('a');
    input.addOption(archives);
    options.addOptionGroup(input);

    final Option statistics = OptionBuilder.withArgName("statistics")
            .withDescription("collect statistics and write a graph into the file given")
            .withLongOpt("statistics").hasOptionalArg().create('s');
    options.addOption(statistics);

    final Option property = OptionBuilder.withArgName("property=value").hasArgs(2).withValueSeparator()
            .withDescription("set configuration property to value").create("D");
    options.addOption(property);

    for (LoaderBackend b : backends) {
        for (Option o : b.getOptions()) {
            options.addOption(o);
        }
    }

    return options;
}

From source file:org.apache.nifi.toolkit.zkmigrator.ZooKeeperMigratorMain.java

private static Options createOptions() {
    final Options options = new Options();
    options.addOption(OPTION_ZK_MIGRATOR_HELP);
    options.addOption(OPTION_ZK_ENDPOINT);
    options.addOption(OPTION_ZK_AUTH_INFO);
    options.addOption(OPTION_FILE);/*from w  w w .  j a  v  a  2 s. c om*/
    options.addOption(OPTION_IGNORE_SOURCE);
    final OptionGroup optionGroupAuth = new OptionGroup().addOption(OPTION_ZK_AUTH_INFO)
            .addOption(OPTION_ZK_KRB_CONF_FILE);
    optionGroupAuth.setRequired(false);
    options.addOptionGroup(optionGroupAuth);
    final OptionGroup optionGroupReadWrite = new OptionGroup().addOption(OPTION_RECEIVE).addOption(OPTION_SEND);
    optionGroupReadWrite.setRequired(true);
    options.addOptionGroup(optionGroupReadWrite);

    return options;
}

From source file:org.apache.oozie.cli.OozieCLI.java

/**
 * Create option for command line option 'job'
 * @return job options//from  w ww.ja  va 2  s. c om
 */
protected Options createJobOptions() {
    Option oozie = new Option(OOZIE_OPTION, true, "Oozie URL");
    Option config = new Option(CONFIG_OPTION, true, "job configuration file '.xml' or '.properties'");
    Option submit = new Option(SUBMIT_OPTION, false, "submit a job");
    Option run = new Option(RUN_OPTION, false, "run a job");
    Option debug = new Option(DEBUG_OPTION, false, "Use debug mode to see debugging statements on stdout");
    Option rerun = new Option(RERUN_OPTION, true,
            "rerun a job  (coordinator requires -action or -date, bundle requires -coordinator or -date)");
    Option dryrun = new Option(DRYRUN_OPTION, false,
            "Dryrun a workflow (since 3.3.2) or coordinator (since 2.0) job without"
                    + " actually executing it");
    Option update = new Option(UPDATE_OPTION, true, "Update coord definition and properties");
    Option showdiff = new Option(SHOWDIFF_OPTION, true,
            "Show diff of the new coord definition and properties with the existing one (default true)");
    Option start = new Option(START_OPTION, true, "start a job");
    Option suspend = new Option(SUSPEND_OPTION, true, "suspend a job");
    Option resume = new Option(RESUME_OPTION, true, "resume a job");
    Option kill = new Option(KILL_OPTION, true, "kill a job (coordinator can mention -action or -date)");
    Option change = new Option(CHANGE_OPTION, true, "change a coordinator or bundle job");
    Option changeValue = new Option(CHANGE_VALUE_OPTION, true,
            "new endtime/concurrency/pausetime value for changing a coordinator job");
    Option info = new Option(INFO_OPTION, true, "info of a job");
    Option poll = new Option(POLL_OPTION, true,
            "poll Oozie until a job reaches a terminal state or a timeout occurs");
    Option offset = new Option(OFFSET_OPTION, true, "job info offset of actions (default '1', requires -info)");
    Option len = new Option(LEN_OPTION, true, "number of actions (default TOTAL ACTIONS, requires -info)");
    Option filter = new Option(FILTER_OPTION, true, "<key><comparator><value>[;<key><comparator><value>]*\n"
            + "(All Coordinator actions satisfying the filters will be retrieved).\n"
            + "key: status or nominaltime\n"
            + "comparator: =, !=, <, <=, >, >=. = is used as OR and others as AND\n"
            + "status: values are valid status like SUCCEEDED, KILLED etc. Only = and != apply for status\n"
            + "nominaltime: time of format yyyy-MM-dd'T'HH:mm'Z'");
    Option order = new Option(ORDER_OPTION, true,
            "order to show coord actions (default ascending order, 'desc' for descending order, requires -info)");
    Option localtime = new Option(LOCAL_TIME_OPTION, false,
            "use local time (same as passing your time zone to -" + TIME_ZONE_OPTION + "). Overrides -"
                    + TIME_ZONE_OPTION + " option");
    Option timezone = new Option(TIME_ZONE_OPTION, true,
            "use time zone with the specified ID (default GMT).\nSee 'oozie info -timezones' for a list");
    Option log = new Option(LOG_OPTION, true, "job log");
    Option errorlog = new Option(ERROR_LOG_OPTION, true, "job error log");
    Option auditlog = new Option(AUDIT_LOG_OPTION, true, "job audit log");
    Option logFilter = new Option(RestConstants.LOG_FILTER_OPTION, true,
            "job log search parameter. Can be specified as -logfilter opt1=val1;opt2=val1;opt3=val1. "
                    + "Supported options are recent, start, end, loglevel, text, limit and debug");
    Option definition = new Option(DEFINITION_OPTION, true, "job definition");
    Option config_content = new Option(CONFIG_CONTENT_OPTION, true, "job configuration");
    Option verbose = new Option(VERBOSE_OPTION, false, "verbose mode");
    Option action = new Option(ACTION_OPTION, true,
            "coordinator rerun/kill on action ids (requires -rerun/-kill); coordinator log retrieval on action ids"
                    + "(requires -log)");
    Option date = new Option(DATE_OPTION, true, "coordinator/bundle rerun on action dates (requires -rerun); "
            + "coordinator log retrieval on action dates (requires -log)");
    Option rerun_coord = new Option(COORD_OPTION, true, "bundle rerun on coordinator names (requires -rerun)");
    Option rerun_refresh = new Option(RERUN_REFRESH_OPTION, false,
            "re-materialize the coordinator rerun actions (requires -rerun)");
    Option rerun_nocleanup = new Option(RERUN_NOCLEANUP_OPTION, false,
            "do not clean up output-events of the coordinator rerun actions (requires -rerun)");
    Option rerun_failed = new Option(RERUN_FAILED_OPTION, false,
            "runs the failed workflow actions of the coordinator actions (requires -rerun)");
    Option property = OptionBuilder.withArgName("property=value").hasArgs(2).withValueSeparator()
            .withDescription("set/override value for given property").create("D");
    Option getAllWorkflows = new Option(ALL_WORKFLOWS_FOR_COORD_ACTION, false,
            "Get workflow jobs corresponding to a coordinator action including all the reruns");
    Option ignore = new Option(IGNORE_OPTION, true, "change status of a coordinator job or action to IGNORED"
            + " (-action required to ignore coord actions)");
    Option timeout = new Option(TIMEOUT_OPTION, true,
            "timeout in minutes (default is 30, negative values indicate no " + "timeout, requires -poll)");
    timeout.setType(Integer.class);
    Option interval = new Option(INTERVAL_OPTION, true,
            "polling interval in minutes (default is 5, requires -poll)");
    interval.setType(Integer.class);

    Option slaDisableAlert = new Option(SLA_DISABLE_ALERT, true,
            "disables sla alerts for the job and its children");
    Option slaEnableAlert = new Option(SLA_ENABLE_ALERT, true,
            "enables sla alerts for the job and its children");
    Option slaChange = new Option(SLA_CHANGE, true,
            "Update sla param for jobs, supported param are should-start, should-end, nominal-time and max-duration");
    Option coordActionMissingDependencies = new Option(COORD_ACTION_MISSING_DEPENDENCIES, true,
            "List missing dependencies of a coord action. To specify multiple actions, use with -action or -date option.");

    Option doAs = new Option(DO_AS_OPTION, true, "doAs user, impersonates as the specified user");

    Option workflowActionRetries = new Option(WORKFLOW_ACTIONS_RETRIES, true,
            "Get information of the retry attempts for a given workflow action");

    OptionGroup actions = new OptionGroup();
    actions.addOption(submit);
    actions.addOption(start);
    actions.addOption(run);
    actions.addOption(dryrun);
    actions.addOption(suspend);
    actions.addOption(resume);
    actions.addOption(kill);
    actions.addOption(change);
    actions.addOption(update);
    actions.addOption(info);
    actions.addOption(rerun);
    actions.addOption(log);
    actions.addOption(errorlog);
    actions.addOption(auditlog);
    actions.addOption(definition);
    actions.addOption(config_content);
    actions.addOption(ignore);
    actions.addOption(poll);
    actions.addOption(slaDisableAlert);
    actions.addOption(slaEnableAlert);
    actions.addOption(slaChange);
    actions.addOption(workflowActionRetries);
    actions.addOption(coordActionMissingDependencies);
    actions.setRequired(true);
    Options jobOptions = new Options();
    jobOptions.addOption(oozie);
    jobOptions.addOption(doAs);
    jobOptions.addOption(config);
    jobOptions.addOption(property);
    jobOptions.addOption(changeValue);
    jobOptions.addOption(localtime);
    jobOptions.addOption(timezone);
    jobOptions.addOption(verbose);
    jobOptions.addOption(debug);
    jobOptions.addOption(offset);
    jobOptions.addOption(len);
    jobOptions.addOption(filter);
    jobOptions.addOption(order);
    jobOptions.addOption(action);
    jobOptions.addOption(date);
    jobOptions.addOption(rerun_coord);
    jobOptions.addOption(rerun_refresh);
    jobOptions.addOption(rerun_nocleanup);
    jobOptions.addOption(rerun_failed);
    jobOptions.addOption(getAllWorkflows);
    jobOptions.addOptionGroup(actions);
    jobOptions.addOption(logFilter);
    jobOptions.addOption(timeout);
    jobOptions.addOption(interval);
    addAuthOptions(jobOptions);
    jobOptions.addOption(showdiff);

    //Needed to make dryrun and update mutually exclusive options
    OptionGroup updateOption = new OptionGroup();
    updateOption.addOption(dryrun);
    jobOptions.addOptionGroup(updateOption);

    return jobOptions;
}

From source file:org.apache.openmeetings.cli.Admin.java

private Options buildOptions() {
    Options options = new Options();
    OptionGroup group = new OptionGroup()
            .addOption(new OmOption("h", 0, "h", "help", false, "prints this message"))
            .addOption(new OmOption("b", 1, "b", "backup", false, "Backups OM"))
            .addOption(new OmOption("r", 2, "r", "restore", false, "Restores OM"))
            .addOption(new OmOption("i", 3, "i", "install", false, "Fill DB table, and make OM usable"))
            .addOption(new OmOption("l", 3, "l", "LDAP", false, "Import LDAP users into DB"))
            .addOption(new OmOption("f", 4, "f", "files", false, "File operations - statictics/cleanup"));
    group.setRequired(true);
    options.addOptionGroup(group);/*from  w  ww  .j  a  va  2 s.  co m*/
    //general
    options.addOption(new OmOption(null, "v", "verbose", false, "verbose error messages"));
    //backup/restore
    options.addOption(new OmOption("b", null, "exclude-files", false,
            "should backup exclude files [default: include]", true));
    options.addOption(new OmOption("b,r,i", "file", null, true, "file used for backup/restore/install", "b"));
    //install
    options.addOption(new OmOption("i", "user", null, true, "Login name of the default user, minimum "
            + USER_LOGIN_MINIMUM_LENGTH + " characters (mutually exclusive with 'file')"));
    options.addOption(new OmOption("i", "email", null, true,
            "Email of the default user (mutually exclusive with 'file')"));
    options.addOption(new OmOption("i", "group", null, true,
            "The name of the default user group (mutually exclusive with 'file')"));
    options.addOption(new OmOption("i", "tz", null, true,
            "Default server time zone, and time zone for the selected user (mutually exclusive with 'file')"));
    options.addOption(new OmOption("i", null, "password", true, "Password of the default user, minimum "
            + USER_PASSWORD_MINIMUM_LENGTH + " characters (will be prompted if not set)", true));
    options.addOption(new OmOption("i", null, "system-email-address", true,
            "System e-mail address [default: " + cfg.mailReferer + "]", true));
    options.addOption(new OmOption("i", null, "smtp-server", true,
            "SMTP server for outgoing e-mails [default: " + cfg.smtpServer + "]", true));
    options.addOption(new OmOption("i", null, "smtp-port", true,
            "SMTP server for outgoing e-mails [default: " + cfg.smtpPort + "]", true));
    options.addOption(new OmOption("i", null, "email-auth-user", true,
            "Email auth username (anonymous connection will be used if not set)", true));
    options.addOption(new OmOption("i", null, "email-auth-pass", true,
            "Email auth password (anonymous connection will be used if not set)", true));
    options.addOption(
            new OmOption("i", null, "email-use-tls", false, "Is secure e-mail connection [default: no]", true));
    options.addOption(new OmOption("i", null, "skip-default-rooms", false,
            "Do not create default rooms [created by default]", true));
    options.addOption(new OmOption("i", null, "disable-frontend-register", false,
            "Do not allow front end register [allowed by default]", true));
    options.addOption(new OmOption("i", null, "default-language", true,
            "Default system language as int [1 by default]", true));

    options.addOption(new OmOption("i", null, "db-type", true, "The type of the DB to be used", true));
    options.addOption(new OmOption("i", null, "db-host", true, "DNS name or IP address of database", true));
    options.addOption(new OmOption("i", null, "db-port", true, "Database port", true));
    options.addOption(new OmOption("i", null, "db-name", true, "The name of Openmeetings database", true));
    options.addOption(
            new OmOption("i", null, "db-user", true, "User with write access to the DB specified", true));
    options.addOption(new OmOption("i", null, "db-pass", true,
            "Password of the user with write access to the DB specified", true));
    options.addOption(new OmOption("i", null, "drop", false, "Drop database before installation", true));
    options.addOption(new OmOption("i", null, "force", false,
            "Install without checking the existence of old data in the database.", true));
    //files
    options.addOption(new OmOption("f", null, "cleanup", false, "Should intermediate files be clean up", true));
    //ldap
    options.addOption(new OmOption("l", "d", "domain-id", true, "LDAP domain Id", false));
    options.addOption(
            new OmOption("l", null, "print-only", false, "Print users found instead of importing", true));
    return options;
}