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

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

Introduction

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

Prototype

public Option(String opt, String longOpt, boolean hasArg, String description) throws IllegalArgumentException 

Source Link

Document

Creates an Option using the specified parameters.

Usage

From source file:com.alibaba.rocketmq.tools.command.message.QueryMessageSubCommand.java

@Override
public Options buildCommandlineOptions(Options options) {
    Option opt = new Option("t", "topic", true, "topic name");
    opt.setRequired(false);/*w  w  w  .  ja  va2 s .co m*/
    options.addOption(opt);

    opt = new Option("i", "msgId", true, "Message Id");
    opt.setRequired(false);
    options.addOption(opt);

    opt = new Option("k", "msgKey", true, "Message Key");
    opt.setRequired(false);
    options.addOption(opt);

    opt = new Option("f", "fallbackHours", true, "Fallback Hours");
    opt.setRequired(false);
    options.addOption(opt);

    return options;
}

From source file:com.nishtahir.alang.ALang.java

/**
 * @param args command line arguments/*  ww w  .j a  va  2  s .c o  m*/
 */
public ALang(final String[] args) {
    commandLineOptions = new Options();

    commandLineOptions.addOption(new Option("h", "help", false, "print this message"));
    commandLineOptions.addOption(new Option("version", false, "more info about " + APP_NAME));
    commandLineOptions.addOption(new Option("v", "verbose", false, "show more information"));

    commandLineOptions.addOption(new Option("c", "compiler", true, "compiler option [pico]"));

    try {
        List<String> filesToParse = parseCommandLineArguments(args);
        if (filesToParse != null && !filesToParse.isEmpty()) {
            parseFiles(filesToParse);
        }
    } catch (ParseException e) {
        LOGGER.error("An error occurred while parsing command line", e);
    } catch (IOException e) {
        LOGGER.error("An IOException occurred", e);
    }
}

From source file:com.zimbra.cs.mailbox.calendar.FixCalendarTZUtil.java

@Override
protected void setupCommandLineOptions() {
    super.setupCommandLineOptions();
    Options options = getOptions();//  www. j  av a2 s . co  m
    Option rulefileOpt = new Option(null, O_RULEFILE, true, "xml file containing fixup rules");
    rulefileOpt.setRequired(true);
    options.addOption(rulefileOpt);
    Option accountOpt = new Option(O_ACCOUNT, "account", true,
            "account email addresses seperated by white space or \"all\" for all accounts");
    accountOpt.setRequired(true);
    accountOpt.setArgs(Option.UNLIMITED_VALUES);
    options.addOption(accountOpt);
    options.addOption(new Option(null, O_AFTER, true,
            "fixup calendar items after this time; defaults to beginning of 2007"));
    options.addOption(new Option(null, O_SYNC, false, "run synchronously; default is asynchronous"));
    options.addOption(SoapCLI.OPT_AUTHTOKEN);
    options.addOption(SoapCLI.OPT_AUTHTOKENFILE);
}

From source file:com.alibaba.rocketmq.tools.command.cluster.CLusterSendMsgRTCommand.java

@Override
public Options buildCommandlineOptions(Options options) {
    Option opt = new Option("a", "amout", true, "message amout | default 100");
    opt.setRequired(false);//from   w w w .ja  v a 2  s.com
    options.addOption(opt);

    opt = new Option("s", "size", true, "message size | default 128 Byte");
    opt.setRequired(true);
    options.addOption(opt);

    opt = new Option("c", "cluster", true, "cluster name | default display all cluster");
    opt.setRequired(false);
    options.addOption(opt);

    opt = new Option("p", "print log", true, "print as tlog | default false");
    opt.setRequired(false);
    options.addOption(opt);

    opt = new Option("m", "machine room", true, "machine room name | default noname");
    opt.setRequired(false);
    options.addOption(opt);

    opt = new Option("i", "interval", true, "print interval | default 10 seconds");
    opt.setRequired(false);
    options.addOption(opt);

    return options;
}

From source file:com.huawei.streaming.cql.OptionsProcessor.java

@SuppressWarnings("static-access")
private void initOptions() {
    // -f <query-file>
    options.addOption(OptionBuilder.hasArg().withLongOpt("file").withArgName("filename")
            .withDescription("CQL from files").create('f'));

    // [-S|--silent]
    options.addOption(new Option("s", "silent", false, "Silent mode in interactive shell"));

    // [-H|--help]
    options.addOption(new Option("h", "help", false, "Print help information"));
}

From source file:io.warp10.worf.WorfCLI.java

public WorfCLI() {
    options.addOption(new Option(KEYSTORE, "keystore", true,
            "configuration file for generating tokens inside templates"));
    options.addOption(new Option(OUTPUT, "output", true, "output configuration destination file"));
    options.addOption(new Option(TOKEN, "tokens", false, "generate read/write tokens"));
    options.addOption(new Option("f", "format", false, "output tokens format. (default JSON)"));

    OptionGroup groupProducerUID = new OptionGroup();
    groupProducerUID.addOption(new Option(UUIDGEN_PRODUCER, "producer-uuid-gen", false,
            "creates a new universally unique identifier for the producer"));
    groupProducerUID.addOption(new Option(P_UUID, "producer-uuid", true, "data producer uuid"));

    OptionGroup groupOwnerUID = new OptionGroup();
    groupOwnerUID.addOption(new Option(UUIDGEN_OWNER, "owner-uuid-gen", false,
            "creates a new universally unique identifier for the owner"));
    groupOwnerUID/*from ww w .j  a  v a  2  s.c  o  m*/
            .addOption(new Option(O_UUID, "owner-uuid", true, "data owner uuid (producer uuid by default)"));

    options.addOptionGroup(groupProducerUID);
    options.addOptionGroup(groupOwnerUID);

    options.addOption(new Option(APPNAME, "app-name", true,
            "token application name. Used by token option or @warp:writeToken@ template"));
    options.addOption(new Option(TTL, "ttl", true,
            "token time to live (ms). Used by token option or @warp:writeToken@ template"));

    options.addOption(HELP, "help", false, "show help.");
    options.addOption(VERBOSE, "verbose", false, "Verbose mode");
    options.addOption(VERSION, "version", false, "Print version number and return");
    options.addOption(INTERACTIVE, "interactive", false, "Interactive mode, all other options are ignored");
}

From source file:ditl.cli.ConvertApp.java

@Override
protected void initOptions() {
    options.addOption(new Option("f", forceOption, false, "Force overwrite existing traces."));
    options.addOption(null, storeOutputOption, true, "Name of store to output new traces to");
}

From source file:com.geeksaga.light.tools.Main.java

private Options getOptions() {
    Option attachOption = new Option("a", "attach", true, "attach java process");
    attachOption.setArgs(Option.UNLIMITED_VALUES);
    attachOption.setArgName("process ID");

    Options options = new Options();
    options.addOption(attachOption);//from  w w  w .  j  a  v  a  2s .  co m
    options.addOption(new Option("p", "process", false, "find java process"));
    options.addOption(new Option("s", "self", false, "self attach java process"));

    return options;
}

From source file:com.zimbra.cs.store.file.BlobDeduperUtil.java

private BlobDeduperUtil() {
    options = new Options();

    options.addOption(new Option("h", LO_HELP, false, "Display this help message."));
    options.addOption(new Option("v", LO_VERBOSE, false, "Display stack trace on error."));

    Option o = new Option(null, LO_VOLUMES, true,
            "Specify which volumes to dedupe.  If not specified, dedupe all volumes.");
    o.setArgName("volume-ids");
    options.addOption(o);/* w  w w .  j  a va  2s .c om*/
}

From source file:de.tudarmstadt.lt.lm.app.FilterLines.java

@SuppressWarnings("static-access")
public FilterLines(String args[]) {
    Options opts = new Options();

    opts.addOption(new Option("?", "help", false, "display this message"));
    opts.addOption(OptionBuilder.withLongOpt("file").withArgName("name").hasArg().withDescription(
            "Specify the file or directory that contains '.txt' files that are used as source for testing perplexity with the specified language model. Specify '-' to pipe from stdin. (default: '-').")
            .create("f"));
    opts.addOption(OptionBuilder.withLongOpt("out").withArgName("name").hasArg()
            .withDescription("Specify the output file. Specify '-' to use stdout. (default: '-').")
            .create("o"));
    opts.addOption(OptionBuilder.withLongOpt("runparallel")
            .withDescription("Specify if processing should happen in parallel.").create("p"));
    opts.addOption(OptionBuilder.withLongOpt("maximum-perplexity").withArgName("perplexity-value").hasArg()
            .withDescription(//from   w w  w .  j  a  v  a 2s.c o  m
                    "Specify the maximum perplexity value (with oov / 5th col) allowed, everything greater this value will not be printed. (default: '1000').")
            .create("m"));

    try {
        CommandLine cmd = new ExtendedGnuParser(true).parse(opts, args);
        if (cmd.hasOption("help"))
            CliUtils.print_usage_quit(System.err, StartLM.class.getSimpleName(), opts, USAGE_HEADER, null, 0);

        _file = cmd.getOptionValue("file", "-");
        _out = cmd.getOptionValue("out", "-");
        _parallel = cmd.hasOption("runparallel");
        _max_perp = Double.parseDouble(cmd.getOptionValue("maximum-perplexity", "1000"));

    } catch (Exception e) {
        LOG.error("{}: {}", e.getClass().getSimpleName(), e.getMessage());
        CliUtils.print_usage_quit(System.err, getClass().getSimpleName(), opts, USAGE_HEADER,
                String.format("%s: %s%n", e.getClass().getSimpleName(), e.getMessage()), 1);
    }
}