Search in sources :

Example 1 with OptionGroup

use of org.apache.commons.cli.OptionGroup in project goci by EBISPOT.

the class ImportExportApplication method bindOptions.

private Options bindOptions() {
    Options options = new Options();
    // help
    Option helpOption = new Option("h", "help", false, "Print the help");
    options.addOption(helpOption);
    // options are...
    // -n --ncbi        (write out NCBI export file)
    // -d --download    (write out downloads file)
    // -f --file        (file to load in)
    // -o --out         (file to write out to)
    // -a --download_alt  (write out alternative downloads file)
    // -s --stats       (write out catalog meta data)
    // add input options
    OptionGroup modeGroup = new OptionGroup();
    modeGroup.setRequired(true);
    Option ncbiOption = new Option("n", "ncbi", false, "NCBI - generate an export of the GWAS catalog to send to the NCBI for mapping");
    ncbiOption.setRequired(false);
    modeGroup.addOption(ncbiOption);
    Option downloadOption = new Option("d", "download", false, "Download - generate an export of the GWAS catalog suitable for download");
    downloadOption.setRequired(false);
    modeGroup.addOption(downloadOption);
    Option downloadAltOption = new Option("a", "download_alt", false, "Download alternative - generate an export of the GWAS catalog, including ontology mappings, suitable for download");
    downloadAltOption.setRequired(false);
    modeGroup.addOption(downloadAltOption);
    Option statsOption = new Option("s", "stats", false, "Stats - generate the meta data for the GWAS Catalog published content");
    statsOption.setRequired(false);
    modeGroup.addOption(statsOption);
    options.addOptionGroup(modeGroup);
    // add input file arguments
    OptionGroup fileGroup = new OptionGroup();
    fileGroup.setRequired(true);
    Option inOption = new Option("f", "file", true, "Input file - file where the NCBI mapped data can be found");
    inOption.setArgName("file");
    inOption.setRequired(false);
    fileGroup.addOption(inOption);
    // add output file arguments
    Option outOption = new Option("o", "out", true, "Output file - file to write the chosen data export to");
    outOption.setArgName("file");
    outOption.setRequired(false);
    fileGroup.addOption(outOption);
    options.addOptionGroup(fileGroup);
    return options;
}
Also used : Options(org.apache.commons.cli.Options) OptionGroup(org.apache.commons.cli.OptionGroup) Option(org.apache.commons.cli.Option)

Example 2 with OptionGroup

use of org.apache.commons.cli.OptionGroup in project zm-mailbox by Zimbra.

the class SoapCLI method getAllOptions.

/**
     * Returns an <tt>Options</tt> object that combines the standard options
     * and the hidden ones.
     */
@SuppressWarnings("unchecked")
private Options getAllOptions() {
    Options newOptions = new Options();
    Set<OptionGroup> groups = new HashSet<OptionGroup>();
    Options[] optionses = new Options[] { mOptions, mHiddenOptions };
    for (Options options : optionses) {
        for (Option opt : (Collection<Option>) options.getOptions()) {
            OptionGroup group = options.getOptionGroup(opt);
            if (group != null) {
                groups.add(group);
            } else {
                newOptions.addOption(opt);
            }
        }
    }
    for (OptionGroup group : groups) {
        newOptions.addOptionGroup(group);
    }
    return newOptions;
}
Also used : Options(org.apache.commons.cli.Options) OptionGroup(org.apache.commons.cli.OptionGroup) Collection(java.util.Collection) Option(org.apache.commons.cli.Option) HashSet(java.util.HashSet)

Example 3 with OptionGroup

use of org.apache.commons.cli.OptionGroup in project zm-mailbox by Zimbra.

the class VolumeCLI method setupCommandLineOptions.

@Override
protected void setupCommandLineOptions() {
    super.setupCommandLineOptions();
    Options options = getOptions();
    OptionGroup og = new OptionGroup();
    og.addOption(new Option(O_A, "add", false, "Adds a volume."));
    og.addOption(new Option(O_D, "delete", false, "Deletes a volume."));
    og.addOption(new Option(O_L, "list", false, "Lists volumes."));
    og.addOption(new Option(O_E, "edit", false, "Edits a volume."));
    og.addOption(new Option(O_DC, "displayCurrent", false, "Displays the current volumes."));
    og.addOption(new Option(O_SC, "setCurrent", false, "Sets the current volume."));
    og.addOption(new Option(O_TS, "turnOffSecondary", false, "Turns off the current secondary message volume"));
    og.setRequired(true);
    options.addOptionGroup(og);
    options.addOption(O_ID, "id", true, "Volume ID");
    options.addOption(O_T, "type", true, "Volume type (primaryMessage, secondaryMessage, or index)");
    options.addOption(O_N, "name", true, "volume name");
    options.addOption(O_P, "path", true, "Root path");
    options.addOption(O_C, "compress", true, "Compress blobs; \"true\" or \"false\"");
    options.addOption(O_CT, "compressionThreshold", true, "Compression threshold; default 4KB");
    options.addOption(SoapCLI.OPT_AUTHTOKEN);
    options.addOption(SoapCLI.OPT_AUTHTOKENFILE);
}
Also used : Options(org.apache.commons.cli.Options) OptionGroup(org.apache.commons.cli.OptionGroup) Option(org.apache.commons.cli.Option)

Example 4 with OptionGroup

use of org.apache.commons.cli.OptionGroup in project incubator-systemml by apache.

the class DMLScript method createCLIOptions.

/**
	 * Creates an {@link Options} instance for the command line parameters
	 *  As of SystemML 0.13, Apache Commons CLI 1.2 is transitively in the classpath
	 *  However the most recent version of Apache Commons CLI is 1.4
	 *  Creating CLI options is done using Static methods. This obviously makes it
	 *  thread unsafe. Instead of {@link OptionBuilder}, CLI 1.4 uses Option.Builder which
	 *  has non-static methods.
	 * @return an appropriate instance of {@link Options}
	 */
@SuppressWarnings("static-access")
public static Options createCLIOptions() {
    Options options = new Options();
    Option nvargsOpt = OptionBuilder.withArgName("key=value").withDescription("parameterizes DML script with named parameters of the form <key=value>; <key> should be a valid identifier in DML/PyDML").hasArgs().create("nvargs");
    Option argsOpt = OptionBuilder.withArgName("argN").withDescription("specifies positional parameters; first value will replace $1 in DML program; $2 will replace 2nd and so on").hasArgs().create("args");
    Option configOpt = OptionBuilder.withArgName("filename").withDescription("uses a given configuration file (can be on local/hdfs/gpfs; default values in SystemML-config.xml").hasArg().create("config");
    Option cleanOpt = OptionBuilder.withDescription("cleans up all SystemML working directories (FS, DFS); all other flags are ignored in this mode. \n").create("clean");
    Option statsOpt = OptionBuilder.withArgName("count").withDescription("monitors and reports caching/recompilation statistics; heavy hitter <count> is 10 unless overridden; default off").hasOptionalArg().create("stats");
    Option explainOpt = OptionBuilder.withArgName("level").withDescription("explains plan levels; can be 'hops' / 'runtime'[default] / 'recompile_hops' / 'recompile_runtime'").hasOptionalArg().create("explain");
    Option execOpt = OptionBuilder.withArgName("mode").withDescription("sets execution mode; can be 'hadoop' / 'singlenode' / 'hybrid'[default] / 'hybrid_spark' / 'spark'").hasArg().create("exec");
    Option gpuOpt = OptionBuilder.withArgName("force").withDescription("uses CUDA instructions when reasonable; set <force> option to skip conservative memory estimates and use GPU wherever possible; default off").hasOptionalArg().create("gpu");
    Option debugOpt = OptionBuilder.withDescription("runs in debug mode; default off").create("debug");
    Option pythonOpt = OptionBuilder.withDescription("parses Python-like DML").create("python");
    Option fileOpt = OptionBuilder.withArgName("filename").withDescription("specifies dml/pydml file to execute; path can be local/hdfs/gpfs (prefixed with appropriate URI)").isRequired().hasArg().create("f");
    Option scriptOpt = OptionBuilder.withArgName("script_contents").withDescription("specified script string to execute directly").isRequired().hasArg().create("s");
    Option helpOpt = OptionBuilder.withDescription("shows usage message").create("help");
    OptionGroup fileOrScriptOpt = new OptionGroup();
    // Either a clean(-clean), a file(-f), a script(-s) or help(-help) needs to be specified
    fileOrScriptOpt.addOption(scriptOpt);
    fileOrScriptOpt.addOption(fileOpt);
    fileOrScriptOpt.addOption(cleanOpt);
    fileOrScriptOpt.addOption(helpOpt);
    fileOrScriptOpt.setRequired(true);
    OptionGroup argsOrNVArgsOpt = new OptionGroup();
    // Either -args or -nvargs
    argsOrNVArgsOpt.addOption(nvargsOpt).addOption(argsOpt);
    options.addOption(configOpt);
    options.addOption(cleanOpt);
    options.addOption(statsOpt);
    options.addOption(explainOpt);
    options.addOption(execOpt);
    options.addOption(gpuOpt);
    options.addOption(debugOpt);
    options.addOption(pythonOpt);
    options.addOptionGroup(fileOrScriptOpt);
    options.addOptionGroup(argsOrNVArgsOpt);
    options.addOption(helpOpt);
    return options;
}
Also used : Options(org.apache.commons.cli.Options) OptionGroup(org.apache.commons.cli.OptionGroup) Option(org.apache.commons.cli.Option)

Example 5 with OptionGroup

use of org.apache.commons.cli.OptionGroup in project ignite by apache.

the class GridRandomCommandLineLoader method createOptions.

/**
     * Creates cli options.
     *
     * @return Command line options
     */
private static Options createOptions() {
    Options options = new Options();
    Option help = new Option(OPTION_HELP, "print this message");
    Option cfg = new Option(null, OPTION_CFG, true, "path to Spring XML configuration file.");
    cfg.setValueSeparator('=');
    cfg.setType(String.class);
    Option minTtl = new Option(null, OPTION_MIN_TTL, true, "node minimum time to live.");
    minTtl.setValueSeparator('=');
    minTtl.setType(Long.class);
    Option maxTtl = new Option(null, OPTION_MAX_TTL, true, "node maximum time to live.");
    maxTtl.setValueSeparator('=');
    maxTtl.setType(Long.class);
    Option duration = new Option(null, OPTION_DURATION, true, "run timeout.");
    duration.setValueSeparator('=');
    duration.setType(Long.class);
    Option log = new Option(null, OPTION_LOG_CFG, true, "path to log4j configuration file.");
    log.setValueSeparator('=');
    log.setType(String.class);
    options.addOption(help);
    OptionGroup grp = new OptionGroup();
    grp.setRequired(true);
    grp.addOption(cfg);
    grp.addOption(minTtl);
    grp.addOption(maxTtl);
    grp.addOption(duration);
    grp.addOption(log);
    options.addOptionGroup(grp);
    return options;
}
Also used : Options(org.apache.commons.cli.Options) OptionGroup(org.apache.commons.cli.OptionGroup) Option(org.apache.commons.cli.Option)

Aggregations

OptionGroup (org.apache.commons.cli.OptionGroup)14 Option (org.apache.commons.cli.Option)13 Options (org.apache.commons.cli.Options)11 Collection (java.util.Collection)1 HashSet (java.util.HashSet)1 BasicParser (org.apache.commons.cli.BasicParser)1 CommandLine (org.apache.commons.cli.CommandLine)1 CommandLineParser (org.apache.commons.cli.CommandLineParser)1 ParseException (org.apache.commons.cli.ParseException)1