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

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

Introduction

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

Prototype

OptionGroup

Source Link

Usage

From source file:esg.node.security.shell.cmds.ESGFassociate.java

public void doInitOptions() {
    getOptions().addOption("n", "no_prompt", false, "suppress request confirmation before making associations");

    Option username = OptionBuilder.withArgName("username").hasArg(true)
            .withDescription("user name you wish to associate").withLongOpt("username").isRequired(true)
            .create("u");
    getOptions().addOption(username);/*from  w w  w .jav a2s  .c o  m*/

    Option groupname = OptionBuilder.withArgName("groupname").hasArg(true)
            .withDescription("group name you wish to associate").withLongOpt("groupname").isRequired(false)
            .create("g");
    getOptions().addOption(groupname);

    Option rolename = OptionBuilder.withArgName("rolename").hasArg(true)
            .withDescription("role name you wish to associate").withLongOpt("rolename").isRequired(false)
            .create("r");
    getOptions().addOption(rolename);

    Option add = new Option("add", false, "creates a permission entry from the given (user,group,role) tuple");
    Option remove = new Option("remove", false, "removes the specified group and role from specified user");
    Option removeGroupFromUser = new Option("remove_group_from_user", false,
            "removes the specified group from specified user");
    Option removeRoleFromUser = new Option("remove_role_from_user", false,
            "removes the specified role from specified user");
    Option removeAll = new Option("remove_all", false, "removes all group and roles associated with user");

    OptionGroup directiveOptionGroup = new OptionGroup();
    directiveOptionGroup.addOption(add);
    directiveOptionGroup.addOption(remove);
    directiveOptionGroup.addOption(removeGroupFromUser);
    directiveOptionGroup.addOption(removeRoleFromUser);
    directiveOptionGroup.addOption(removeAll);
    getOptions().addOptionGroup(directiveOptionGroup);
}

From source file:io.github.eternalbits.compactvd.CompactVD.java

private static Options buildOptions() {
    Options options = new Options();
    OptionGroup source = new OptionGroup();
    source.addOption(Option.builder("i").longOpt("inplace").desc("compact <src> image file in place").hasArgs()
            .argName("src").build());
    source.addOption(Option.builder("c").longOpt("copy").desc("copy <src> to a new, optimized image").hasArgs()
            .argName("src").build());
    source.addOption(Option.builder("d").longOpt("dump").desc("print <src> disk image details").hasArgs()
            .argName("src").build());
    source.setRequired(true);//from   w  ww . j a va 2s .  c  o  m
    options.addOptionGroup(source);
    options.addOptionGroup(new OptionGroup()
            .addOption(Option.builder("u").longOpt("drop-unused")
                    .desc("drop space not in use by system and files").build())
            .addOption(Option.builder("U").longOpt("keep-unused")
                    .desc("keep space not in use by system and files").build()));
    options.addOptionGroup(new OptionGroup()
            .addOption(Option.builder("z").longOpt("drop-zeroed").desc("drop space filled with zeros").build())
            .addOption(
                    Option.builder("Z").longOpt("keep-zeroed").desc("keep space filled with zeros").build()));
    options.addOption(Option.builder("w").longOpt("write").desc("set <out> as destination file for copy")
            .hasArgs().argName("out").build());
    options.addOption(Option.builder("f").longOpt("format")
            .desc("copy output format: VDI, VMDK, VHD or IMG|RAW").hasArgs().argName("fmt").build());
    options.addOption(Option.builder("o").longOpt("overwrite").desc("overwrite existing file on copy").build());
    options.addOption(Option.builder("v").longOpt("verbose").desc("explain what is being done").build());
    return options;
}

From source file:co.runrightfast.vertx.core.application.RunRightFastVertxApplicationLauncher.java

private static Options cliOptions() {
    final Options options = new Options().addOptionGroup(new OptionGroup()
            .addOption(Option.builder("v").longOpt("version").desc("Show the application version").build())
            .addOption(Option.builder("h").longOpt("help").desc("Print usage").build())
            .addOption(Option.builder("c").longOpt("config").desc("Show the application configuration as JSON")
                    .build()));/* w  ww.  jav a 2s .c  om*/
    return options;
}

From source file:net.nharyes.drivecopy.Main.java

private void composeOptions() {

    // file option
    Option file = OptionBuilder.create('f');
    file.setLongOpt("file");
    file.setArgs(1);/*  w  ww .  jav  a  2 s.  com*/
    file.setArgName("path");
    file.setDescription("where path is the file to upload/download/replace.");

    // directory option
    Option directory = OptionBuilder.create('d');
    directory.setLongOpt("directory");
    directory.setArgs(1);
    directory.setArgName("path");
    directory.setDescription(
            "where path is the local directory to upload/download/replace (it will be archived into a single remote file).");

    // file and directory group
    OptionGroup group = new OptionGroup();
    group.addOption(file);
    group.addOption(directory);
    group.setRequired(true);
    options.addOptionGroup(group);

    // compression level option
    Option level = OptionBuilder.create('l');
    level.setLongOpt("level");
    level.setArgs(1);
    level.setArgName("num");
    level.setOptionalArg(true);
    level.setType(Integer.class);
    level.setDescription(
            "where num is the compression level from 0 to 9. Used when uploading/replacing directories. The default value is 0.");
    options.addOption(level);

    // delete option
    Option delete = OptionBuilder.create('D');
    delete.setLongOpt("delete");
    delete.setOptionalArg(true);
    delete.setType(Boolean.class);
    delete.setDescription("delete local file/directory after remote entry uploaded/replaced.");
    options.addOption(delete);

    // log option
    Option log = OptionBuilder.create('L');
    log.setLongOpt("log");
    log.setArgs(1);
    log.setArgName("file");
    log.setType(String.class);
    log.setDescription("where file is the log file to write");
    options.addOption(log);

    // MIME type option
    Option mimeType = OptionBuilder.create('m');
    mimeType.setLongOpt("mimetype");
    mimeType.setArgs(1);
    mimeType.setArgName("type");
    mimeType.setType(String.class);
    mimeType.setDescription(
            "where type is the MIME type string to set for the remote entry. The default values are 'application/octet-stream' for files and 'application/zip' for compressed directories.");
    options.addOption(mimeType);

    // skip revision option
    Option skipRevision = OptionBuilder.create('s');
    skipRevision.setLongOpt("skiprevision");
    skipRevision.setOptionalArg(true);
    skipRevision.setType(Boolean.class);
    skipRevision.setDescription("do not create a new revision when replacing remote entry.");
    options.addOption(skipRevision);

    // check MD5 option
    Option checkMd5 = OptionBuilder.create('c');
    checkMd5.setLongOpt("checkmd5");
    checkMd5.setOptionalArg(true);
    checkMd5.setType(Boolean.class);
    checkMd5.setDescription(
            "compare uploaded/downloaded local file MD5 summary with the one of the remote entry.");
    options.addOption(checkMd5);

    // check force creation option
    Option forceCreation = OptionBuilder.create('F');
    forceCreation.setLongOpt("force");
    forceCreation.setOptionalArg(true);
    forceCreation.setType(Boolean.class);
    forceCreation.setDescription(
            "forces the creation of the remote entry when replace is selected and the entry doesn't exist.");
    options.addOption(forceCreation);

    // settings file option
    Option settings = OptionBuilder.create('C');
    settings.setLongOpt("configuration");
    settings.setArgs(1);
    settings.setArgName("path");
    settings.setType(String.class);
    settings.setDescription(String.format(
            "where path is the path of the configuration file. The default value is '%s' in the same directory.",
            CONFIGURATION_FILE));
    options.addOption(settings);

    // create folders tree option
    Option tree = OptionBuilder.create('t');
    tree.setLongOpt("tree");
    tree.setOptionalArg(true);
    tree.setType(Boolean.class);
    tree.setDescription("create remote folders tree if one or more remote folders are not found.");
    options.addOption(tree);
}

From source file:com.linkedin.helix.examples.BootstrapProcess.java

@SuppressWarnings("static-access")
private static Options constructCommandLineOptions() {
    Option helpOption = OptionBuilder.withLongOpt(help).withDescription("Prints command-line options info")
            .create();//from  ww w  . j  av a2 s. co m

    Option zkServerOption = OptionBuilder.withLongOpt(zkServer).withDescription("Provide zookeeper address")
            .create();
    zkServerOption.setArgs(1);
    zkServerOption.setRequired(true);
    zkServerOption.setArgName("ZookeeperServerAddress(Required)");

    Option clusterOption = OptionBuilder.withLongOpt(cluster).withDescription("Provide cluster name").create();
    clusterOption.setArgs(1);
    clusterOption.setRequired(true);
    clusterOption.setArgName("Cluster name (Required)");

    Option hostOption = OptionBuilder.withLongOpt(hostAddress).withDescription("Provide host name").create();
    hostOption.setArgs(1);
    hostOption.setRequired(true);
    hostOption.setArgName("Host name (Required)");

    Option portOption = OptionBuilder.withLongOpt(hostPort).withDescription("Provide host port").create();
    portOption.setArgs(1);
    portOption.setRequired(true);
    portOption.setArgName("Host port (Required)");

    Option stateModelOption = OptionBuilder.withLongOpt(stateModel).withDescription("StateModel Type").create();
    stateModelOption.setArgs(1);
    stateModelOption.setRequired(true);
    stateModelOption.setArgName("StateModel Type (Required)");

    // add an option group including either --zkSvr or --configFile
    Option fileOption = OptionBuilder.withLongOpt(configFile)
            .withDescription("Provide file to read states/messages").create();
    fileOption.setArgs(1);
    fileOption.setRequired(true);
    fileOption.setArgName("File to read states/messages (Optional)");

    Option transDelayOption = OptionBuilder.withLongOpt(transDelay).withDescription("Provide state trans delay")
            .create();
    transDelayOption.setArgs(1);
    transDelayOption.setRequired(false);
    transDelayOption.setArgName("Delay time in state transition, in MS");

    OptionGroup optionGroup = new OptionGroup();
    optionGroup.addOption(zkServerOption);
    optionGroup.addOption(fileOption);

    Options options = new Options();
    options.addOption(helpOption);
    // options.addOption(zkServerOption);
    options.addOption(clusterOption);
    options.addOption(hostOption);
    options.addOption(portOption);
    options.addOption(stateModelOption);
    options.addOption(transDelayOption);

    options.addOptionGroup(optionGroup);

    return options;
}

From source file:it.uniud.ailab.dcore.launchers.Launcher.java

/**
 * Generates the command-line options.//  w  w  w  .  j a  v a  2  s  . c  o  m
 */
private static void createOptions() {
    // help message
    options.addOption(Option.builder("h").longOpt("help").desc("Display this message").hasArg(false).build());

    // work modes: evaluation
    options.addOption(Option.builder("e").longOpt("evaluate")
            .desc("Evaluate the pipeline using the DATASET dataset").hasArg(true).argName("DATASET").build());

    // work modes: training
    options.addOption(Option.builder("t").longOpt("training-generation")
            .desc("Generate a training set for machine learning " + "using the DATASET dataset").hasArg(true)
            .argName("DATASET").build());

    // load the pipeline
    options.addOption(Option.builder("c").longOpt("config-file").desc("Use the configuration located in PATH")
            .hasArg(true).argName("FILE").build());

    // load the pipeline-2
    options.addOption(Option.builder("cd").longOpt("config-default")
            .desc("Use one of the default configurations (deprecated)").hasArg(true).argName("PIPELINE")
            .build());

    // load the pipeline-3
    options.addOption(Option.builder("cp").longOpt("config-packaged")
            .desc("Use one of the pre-packaged configurations").hasArg(true).argName("PIPELINE").build());

    OptionGroup inputGroup = new OptionGroup();
    //inputGroup.setRequired(true);

    // load the input file
    inputGroup.addOption(Option.builder("f").longOpt("file").desc("Analyze the input file FILE").hasArg(true)
            .argName("FILE").build());

    // load the input directory
    inputGroup.addOption(Option.builder("d").longOpt("dir")
            .desc("Analyze all files contained in DIR (not recursive)").hasArg(true).argName("DIR").build());

    options.addOptionGroup(inputGroup);

    // set the output file prefix
    options.addOption(Option.builder("o").longOpt("output-folder").desc("Write the output in PATH").hasArg(true)
            .argName("PATH").build());

    // verbose distillation
    options.addOption(Option.builder("v").longOpt("verbose").desc("Print details while extracting")
            .hasArg(false).build());

    options.addOption(Option.builder("l").longOpt("language").desc("LANGUAGE of the input document (optional)")
            .hasArg(true).argName("LANGUAGE").build());
}

From source file:edu.rice.batchsig.bench.BenchSigner.java

@SuppressWarnings("static-access")
static public Options initOptions() {
    Options o = new Options();

    o.addOptionGroup(new OptionGroup()
            .addOption(//  w ww  .  j ava 2 s  .  c  om
                    OptionBuilder.withDescription("Sign a bunch of message from a trace").create("signtrace"))
            .addOption(OptionBuilder.withDescription("Verify messages collected via a trace")
                    .create("verifytrace"))
            .addOption(OptionBuilder.withDescription("Verify messages collected via a trace")
                    .create("makeverifytrace"))
            .addOption(OptionBuilder.withDescription("Sign a bunch of messages created at a target rate")
                    .create("sign"))
            .addOption(OptionBuilder.withDescription("Verify a bunch of messages").create("verify")))
            .addOptionGroup(new OptionGroup()
                    .addOption(OptionBuilder.withDescription("Run test with trace from from Google wave")
                            .create("wave"))
                    .addOption(OptionBuilder.withDescription("Run test with trace from email").create("email"))
                    .addOption(OptionBuilder.withDescription("Run test with trace from twitter")
                            .create("twitter")))
            .addOptionGroup(new OptionGroup()
                    .addOption(
                            OptionBuilder.withDescription("Sign each message one at a time").create("simple"))
                    .addOption(OptionBuilder.withDescription("Sign each message with merkle tree")
                            .create("merkle"))
                    .addOption(OptionBuilder.withDescription("Sign each message with history tree")
                            .create("history")))
            .addOption(OptionBuilder.withDescription("Do longer duration experiments").create("big"))
            //.addOption(OptionBuilder.withDescription("Trace to use").hasArg().create("trace"))
            .addOption(OptionBuilder
                    .withDescription(
                            "Number of senders to generate in verifytrace (prime number, not 43 or 37)")
                    .hasArg().create("verifytracesenders"))
            .addOption(OptionBuilder.withDescription("name of event trace").hasArg().create("eventtrace"))
            .addOption(OptionBuilder.withDescription("name of user logonlogoff trace").hasArg()
                    .create("usertrace"))
            .addOption(
                    OptionBuilder.withDescription("Output file (used when signing)").hasArg().create("output"))
            .addOption(
                    OptionBuilder.withDescription("Input file (used when verifying)").hasArg().create("input"))
            .addOption(OptionBuilder.withDescription("Automatically scale the signing rate").create("autorate"))
            .addOption(OptionBuilder.withDescription("Run at the given timeout").hasArg().create("timeout"))
            .addOption(OptionBuilder.withDescription("Run at the given signing rate").hasArg().create("rate"))
            .addOption(OptionBuilder.withDescription("Run at the given signing rate increment").hasArg()
                    .create("incr"))
            .addOption(OptionBuilder.withDescription("Batchsize when creating the verify trace").hasArg()
                    .create("batchsize"))
            .addOption(OptionBuilder.withDescription("Return help").create('h')).addOption(
                    OptionBuilder.withDescription("Which crypto provider to use").hasArg().create("provider"))
    //.addOption(OptionBuilder.withDescription("When verifying, which signer ID to use").hasArg().create("signerid"))
    ;

    OptionGroup tmp1 = new OptionGroup()
            .addOption(OptionBuilder.withDescription("Use DSA with the given keysize").hasOptionalArg()
                    .create("dsa"))
            .addOption(OptionBuilder.withDescription("Use RSA with the given keysize").hasOptionalArg()
                    .create("rsa"));
    tmp1.setRequired(true);
    o.addOptionGroup(tmp1);

    OptionGroup tmp2 = new OptionGroup().addOption(OptionBuilder.withDescription("Use sha256").create("sha256"))
            .addOption(OptionBuilder.withDescription("Use sha1").create("sha1"));
    tmp2.setRequired(true);
    o.addOptionGroup(tmp2);

    return o;
}

From source file:com.github.lindenb.jvarkit.util.command.Command.java

protected void fillOptions(final Options opts) {
    final OptionGroup g = new OptionGroup();
    g.addOption(createHelpOption());// www.  j  a v  a 2s.  c  om
    g.addOption(createVersionOption());
    opts.addOptionGroup(g);
}

From source file:de.uni_koblenz.jgralab.utilities.rsa2tg.SchemaGraph2XMI.java

/**
 * Processes all command line parameters and returns a {@link CommandLine}
 * object, which holds all values included in the given {@link String}
 * array.//from   ww  w.ja va 2 s. c  o  m
 * 
 * @param args
 *            {@link CommandLine} parameters.
 * @return {@link CommandLine} object, which holds all necessary values.
 */
public static CommandLine processCommandLineOptions(String[] args) {

    // Creates a OptionHandler.
    String toolString = "java " + SchemaGraph2XMI.class.getName();
    String versionString = JGraLab.getInfo(false);

    OptionHandler oh = new OptionHandler(toolString, versionString);

    // Several Options are declared.
    Option output = new Option("o", "output", true, "(required): the output xmi file name");
    output.setRequired(true);
    output.setArgName("file");
    oh.addOption(output);

    Option schemaGraph = new Option("ig", "inputSchemaGraph", true,
            "(required or -i):if set, the schemaGraph is converted into a xmi.");
    schemaGraph.setRequired(false);
    schemaGraph.setArgs(0);
    output.setArgName("file");
    oh.addOption(schemaGraph);

    Option schema = new Option("i", "inputSchema", true,
            "(required or -ig): TG-file of the schema which should be converted into a xmi.");
    schema.setRequired(false);
    schema.setArgName("file");
    oh.addOption(schema);

    // either graph or schema has to be provided
    OptionGroup input = new OptionGroup();
    input.addOption(schemaGraph);
    input.addOption(schema);
    input.setRequired(true);
    oh.addOptionGroup(input);

    Option bidirectional = new Option("b", "bidirectional", false,
            "(optional): If set the EdgeClasses are created as bidirectional associations.");
    bidirectional.setRequired(false);
    oh.addOption(bidirectional);

    return oh.parse(args);
}

From source file:com.sindicetech.siren.demo.loader.Loader.java

private static Options buildOptions() {
    Options options = new Options();
    // input file name and help are exclusive
    OptionGroup fileHelpGroup = new OptionGroup();
    fileHelpGroup.setRequired(true);/*  w  ww .  ja v a2 s  . c  o  m*/
    fileHelpGroup
            .addOption(OptionBuilder.hasArgs(1).hasOptionalArgs(20).withArgName("file or/and folder name[s]")
                    .withDescription("JSON file[s] or/and director(y|ies) with JSON files (max 20)")
                    .withLongOpt(INPUT_FILE_OPT_LONG).isRequired().create(INPUT_FILE_OPT));

    fileHelpGroup.addOption(OptionBuilder.withDescription("prints help and exits").create(HELP_OPT));
    options.addOptionGroup(fileHelpGroup);
    options.addOption(OptionBuilder.hasArgs(1).withArgName("Solr URL")
            .withDescription("Solr URL (default=" + DEFAULT_SOLR_URL + ")").withLongOpt(URL_OPT_LONG)
            .isRequired(false).create(URL_OPT));

    //    options.addOption(OptionBuilder
    //        .hasArgs(1)
    //        .withArgName("batch size")
    //        .withDescription(
    //            "number of documents sent to Solr in one request, max " + MAX_BATCH_SIZE + " (default="
    //                + DEFAULT_BATCH_SIZE + ")").withLongOpt(BATCH_OPT_LONG).isRequired(false)
    //        .create(BATCH_OPT));

    options.addOption(OptionBuilder
            .withDescription("load all files in directories, not only files with JSON file extension")
            .withLongOpt(NO_EXT_CHECK_OPT_LONG).isRequired(false).create(NO_EXT_CHECK_OPT));
    options.addOption(
            OptionBuilder.withDescription("JSON file extension (default=" + DEFAULT_JSON_EXTENSION + ")")
                    .withLongOpt(EXT_OPT_LONG).isRequired(false).create(EXT_OPT));
    options.addOption(OptionBuilder.withDescription("commit after each file, (default=false)")
            .withLongOpt(COMMIT_EACH_LONG).isRequired(false).create(COMMIT_EACH_OPT));

    return options;
}