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

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

Introduction

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

Prototype

public OptionGroup addOption(Option option) 

Source Link

Document

Add the specified Option to this group.

Usage

From source file:org.apache.accumulo.shell.commands.GrantCommand.java

@Override
public Options getOptions() {
    super.getOptions();
    final Options o = new Options();

    final OptionGroup group = new OptionGroup();

    systemOpt = new Option("s", "system", false, "grant a system permission");

    optNamespace = new Option(ShellOptions.namespaceOption, "namespace", true,
            "name of a namespace to operate on");
    optNamespace.setArgName("namespace");

    group.addOption(systemOpt);
    group.addOption(optTableName);/*  w  w w  . ja v a  2  s .c o m*/
    group.addOption(optTablePattern);
    group.addOption(optNamespace);

    o.addOptionGroup(group);
    userOpt = new Option(ShellOptions.userOption, "user", true, "user to operate on");
    userOpt.setArgName("username");
    userOpt.setRequired(true);
    o.addOption(userOpt);

    return o;
}

From source file:org.apache.accumulo.shell.commands.RevokeCommand.java

@Override
public Options getOptions() {
    super.getOptions();
    final Options o = new Options();

    final OptionGroup group = new OptionGroup();

    systemOpt = new Option("s", "system", false, "revoke a system permission");

    optNamespace = new Option(ShellOptions.namespaceOption, "namespace", true,
            "name of a namespace to operate on");
    optNamespace.setArgName("namespace");

    group.addOption(systemOpt);
    group.addOption(optTableName);/*from   w  ww  .  j  av a2s  . c  o  m*/
    group.addOption(optTablePattern);
    group.addOption(optNamespace);

    o.addOptionGroup(group);
    userOpt = new Option(ShellOptions.userOption, "user", true, "user to operate on");
    userOpt.setArgName("username");
    userOpt.setRequired(true);
    o.addOption(userOpt);

    return o;
}

From source file:org.apache.accumulo.shell.commands.SetAuthsCommand.java

@Override
public Options getOptions() {
    final Options o = new Options();
    final OptionGroup setOrClear = new OptionGroup();
    scanOptAuths = new Option("s", "scan-authorizations", true, "scan authorizations to set");
    scanOptAuths.setArgName("comma-separated-authorizations");
    setOrClear.addOption(scanOptAuths);
    clearOptAuths = new Option("c", "clear-authorizations", false, "clear the scan authorizations");
    setOrClear.addOption(clearOptAuths);
    setOrClear.setRequired(true);/*from w  w  w  .  ja  va  2s .  c om*/
    o.addOptionGroup(setOrClear);
    userOpt = new Option(ShellOptions.userOption, "user", true, "user to operate on");
    userOpt.setArgName("user");
    o.addOption(userOpt);
    return o;
}

From source file:org.apache.accumulo.shell.commands.TableOperation.java

@Override
public Options getOptions() {
    final Options o = new Options();

    optTablePattern = new Option("p", "pattern", true, "regex pattern of table names to operate on");
    optTablePattern.setArgName("pattern");

    optTableName = new Option(ShellOptions.tableOption, "table", true, "name of a table to operate on");
    optTableName.setArgName("tableName");

    optNamespace = new Option(ShellOptions.namespaceOption, "namespace", true,
            "name of a namespace to operate on");
    optNamespace.setArgName("namespace");

    final OptionGroup opg = new OptionGroup();

    opg.addOption(optTablePattern);
    opg.addOption(optTableName);//from w w w  .j ava2 s.co  m
    opg.addOption(optNamespace);

    o.addOptionGroup(opg);

    return o;
}

From source file:org.apache.ctakes.ytex.kernel.CytoscapeHelperImpl.java

/**
 * @param args/*from  w  w w  .j a  va 2 s. com*/
 */
@SuppressWarnings("static-access")
public static void main(String args[]) throws ParseException, IOException {
    Options options = new Options();
    options.addOption(OptionBuilder.withArgName("prop").hasArg()
            .withDescription("property file with queries and other parameters. todo desc").create("prop"));
    OptionGroup og = new OptionGroup();
    og.addOption(OptionBuilder.withArgName("network").hasArg().withDescription(
            "create network using specified concept graph and corpus. creates prefix.sif with edges and prefix.node.txt with node data in working directory.")
            .create("network"));
    og.addOption(OptionBuilder.withArgName("concept id").hasArg().withDescription(
            "get all descendants of specified concept, creates concept_id.tree file in working directory")
            .create("subtree"));
    og.setRequired(true);
    options.addOptionGroup(og);
    try {
        CommandLineParser parser = new GnuParser();
        CommandLine line = parser.parse(options, args);
        CytoscapeHelper cytHelper = KernelContextHolder.getApplicationContext().getBean(CytoscapeHelper.class);
        Properties props = new Properties(System.getProperties());
        props.putAll(FileUtil.loadProperties(line.getOptionValue("prop"), true));
        if (!cytHelper.validateProps(props)) {
            printHelp(options);
        } else {
            if (line.hasOption("network")) {
                cytHelper.exportNetwork(line.getOptionValue("network"), props);
            } else if (line.hasOption("subtree")) {
                cytHelper.exportSubtree(line.getOptionValue("subtree"), props);
            } else {
                printHelp(options);
            }
        }
    } catch (ParseException pe) {
        printHelp(options);
    }
}

From source file:org.apache.ctakes.ytex.kernel.pagerank.PageRankServiceImpl.java

public static void main(String args[]) {
    Options options = new Options();
    OptionGroup og = new OptionGroup();
    og.addOption(OptionBuilder.withArgName("concept1,concept2").hasArg()
            .withDescription("compute similarity for specified concept pair").create("sim"));
    og.addOption(OptionBuilder.withArgName("concept1,concept2,...").hasArg()
            .withDescription("personalized pagerank vector for specified concepts ").create("ppr"));
    og.setRequired(true);//from  ww w. j  ava2s.  c  om
    options.addOptionGroup(og);
    try {
        CommandLineParser parser = new GnuParser();
        CommandLine line = parser.parse(options, args);
        Properties ytexProps = new Properties();
        ytexProps.putAll((Properties) KernelContextHolder.getApplicationContext().getBean("ytexProperties"));
        ytexProps.putAll(System.getProperties());
        ConceptDao conceptDao = KernelContextHolder.getApplicationContext().getBean(ConceptDao.class);
        PageRankService pageRankService = KernelContextHolder.getApplicationContext()
                .getBean(PageRankService.class);
        ConceptGraph cg = conceptDao
                .getConceptGraph(ytexProps.getProperty("org.apache.ctakes.ytex.conceptGraphName"));
        if (line.hasOption("sim")) {
            String cs = line.getOptionValue("sim");
            String concept[] = cs.split(",");
            System.out.println(pageRankService.sim(concept[0], concept[1], cg, 30, 1e-4, 0.85));
        } else if (line.hasOption("ppr")) {
            String cs = line.getOptionValue("ppr");
            String concept[] = cs.split(",");
            double weight = 1 / (double) concept.length;
            Map<String, Double> ppv = new HashMap<String, Double>();
            for (String c : concept) {
                ppv.put(c, weight);
            }
            System.out.println(pageRankService.rank(ppv, cg));
        }
    } catch (ParseException pe) {
        HelpFormatter formatter = new HelpFormatter();
        formatter.printHelp("java " + PageRankServiceImpl.class.getName()
                + " compute personalized page rank or similarity.  used for testing purposes", options);
    }

}

From source file:org.apache.ctakes.ytex.KernelLauncher.java

private static Options initOptions() {
    Option oStoreInstanceMap = OptionBuilder.withArgName("instanceMap.obj").hasArg()
            .withDescription("store the instanceMap.  Use prior to running the kernel evaluations in parallel.")
            .create("storeInstanceMap");
    Option oEvaluateKernel = OptionBuilder.withDescription(
            "evaluate kernel specified in application context on the instances. If instanceMap is specified, load instance from file system, else from db.")
            .create("evalKernel");
    Option exportBagOfWords = OptionBuilder.withDescription("exportBagOfWords.  Must specify property file")
            .hasArg().create("exportBagOfWords");
    Option exportType = OptionBuilder.withDescription("exportType.  either libsvm or weka").hasArg()
            .create("exportType");
    Option oLoadInstanceMap = OptionBuilder.withArgName("instanceMap.obj").hasArg()
            .withDescription(/*ww w.j a v  a  2  s . c  o  m*/
                    "load instanceMap from file system instead of from db.  Use after storing instance map.")
            .create("loadInstanceMap");
    Option oEvalMod = OptionBuilder.withDescription("for parallelization, split the instances into mod slices")
            .hasArg().create("mod");
    Option oEvalSlice = OptionBuilder.withDescription(
            "for parallelization, parameter that determines which slice we work on.  If this is not specified, nMod threads will be started to evaluate all slices in parallel.")
            .hasArg().create("slice");
    Option oBeanref = OptionBuilder.withArgName("classpath*:simSvcBeanRefContext.xml").hasArg()
            .withDescription("use specified beanRefContext.xml, default classpath*:simSvcBeanRefContext.xml")
            .create("beanref");
    Option oAppctx = OptionBuilder.withArgName("kernelApplicationContext").hasArg()
            .withDescription("use specified applicationContext, default kernelApplicationContext")
            .create("appctx");
    Option oBeans = OptionBuilder.withArgName("beans-corpus.xml").hasArg()
            .withDescription("use specified beans.xml, no default.  This file is typically required.")
            .create("beans");

    Option oHelp = new Option("help", "print this message");
    Options options = new Options();
    OptionGroup og = new OptionGroup();
    og.addOption(oStoreInstanceMap);
    og.addOption(oEvaluateKernel);
    og.addOption(exportBagOfWords);
    options.addOptionGroup(og);
    // options.addOption(oStoreInstanceMap);
    options.addOption(oEvaluateKernel);
    // options.addOption(exportBagOfWords);
    options.addOption(exportType);
    options.addOption(oLoadInstanceMap);
    options.addOption(oEvalMod);
    options.addOption(oEvalSlice);
    options.addOption(oBeanref);
    options.addOption(oAppctx);
    options.addOption(oBeans);
    options.addOption(oHelp);

    return options;
}

From source file:org.apache.ctakes.ytex.weka.ImportWekaResults.java

private static Options initOptions() {
    Options options = new Options();
    OptionGroup og = new OptionGroup();
    og.addOption(OptionBuilder.withArgName("cvDir").hasArg()
            .withDescription("fold cross-validation results directory").create("cvDir"));
    og.addOption(OptionBuilder.withArgName("document").hasArg().withDescription("document prediction output")
            .create("docPred"));
    og.addOption(OptionBuilder.withArgName("document").hasArg().withDescription("prediction").create("pred"));
    options.addOptionGroup(og);/*  w  ww  .jav  a  2s .com*/
    options.addOption(OptionBuilder.withArgName("algo").hasArg().withDescription("algorithm").create("algo"));
    options.addOption(
            OptionBuilder.withArgName("name").hasArg().withDescription("name").isRequired().create("name"));
    options.addOption(OptionBuilder.withArgName("experiment").hasArg().withDescription("experiment")
            .create("experiment"));
    options.addOption(
            OptionBuilder.withArgName("label").hasArg().withDescription("label / task").create("label"));
    options.addOption(OptionBuilder.withArgName("yes/no").hasArg()
            .withDescription("store probabilities, default yes").create("storeProb"));
    return options;
}

From source file:org.apache.falcon.cli.FalconAdminCLI.java

public Options createAdminOptions() {
    Options adminOptions = new Options();
    Option url = new Option(URL_OPTION, true, "Falcon URL");
    adminOptions.addOption(url);/*from  w  ww.  jav  a 2 s. co m*/

    OptionGroup group = new OptionGroup();
    Option status = new Option(STATUS_OPT, false, "show the current system status");
    Option version = new Option(VERSION_OPT, false, "show Falcon server build version");
    Option stack = new Option(STACK_OPTION, false, "show the thread stack dump");
    Option doAs = new Option(DO_AS_OPT, true, "doAs user");
    Option help = new Option("help", false, "show Falcon help");
    Option debug = new Option(DEBUG_OPTION, false, "Use debug mode to see debugging statements on stdout");
    group.addOption(status);
    group.addOption(version);
    group.addOption(stack);
    group.addOption(help);

    adminOptions.addOptionGroup(group);
    adminOptions.addOption(doAs);
    adminOptions.addOption(debug);
    return adminOptions;
}

From source file:org.apache.falcon.cli.FalconCLI.java

private Options createAdminOptions() {
    Options adminOptions = new Options();
    Option url = new Option(URL_OPTION, true, "Falcon URL");
    adminOptions.addOption(url);/*from   w  w  w.jav a  2  s  .  c  o  m*/

    OptionGroup group = new OptionGroup();
    Option status = new Option(STATUS_OPTION, false, "show the current system status");
    Option version = new Option(VERSION_OPTION, false, "show Falcon server build version");
    Option stack = new Option(STACK_OPTION, false, "show the thread stack dump");
    Option doAs = new Option(DO_AS_OPT, true, "doAs user");
    Option help = new Option("help", false, "show Falcon help");
    group.addOption(status);
    group.addOption(version);
    group.addOption(stack);
    group.addOption(help);

    adminOptions.addOptionGroup(group);
    adminOptions.addOption(doAs);
    return adminOptions;
}