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.netscape.cmstools.tps.authenticator.AuthenticatorModifyCLI.java

public void createOptions() {
    Option option = new Option(null, "action", true,
            "Action: update (default), approve, reject, enable, disable.");
    option.setArgName("action");
    options.addOption(option);/* ww w .ja va 2s .  com*/

    option = new Option(null, "input", true, "Input file containing authenticator properties.");
    option.setArgName("file");
    options.addOption(option);
}

From source file:com.netflix.subtitles.cli.TtmlConverterCmdLineParser.java

public TtmlConverterCmdLineParser() {
    help = new Option("h", "help", false, "Print this message");

    ttml = Option.builder("t").longOpt("ttml")
            .desc("Input TTML file parameters:" + "\n<file> - The TTML file path."
                    + "\n<offsetMS> - Offset in milliseconds to shift captions of the TTML file."
                    + "\n<startMS> - Start time in milliseconds to get captions of the TTML file."
                    + "\n<endMS> - End time in milliseconds to get captions of the TTML file.")
            .numberOfArgs(4).optionalArg(true).argName("file> <offsetTC> <startTC> <endTC").build();
    out = Option.builder("o").longOpt("outputFile").desc("Output iTT file").hasArg().argName("outputFile")
            .build();/*from   ww w . j  av a2  s  . co m*/
    frameRate = Option.builder("f").longOpt("frameRate").desc("Frame rate of result iTT file").hasArg()
            .argName("frameRate").build();

    Stream.of(help, ttml, out, frameRate).forEach(options::addOption);
}

From source file:com.alibaba.rocketmq.tools.command.connection.ConsumerConnectionSubCommand.java

@Override
public Options buildCommandlineOptions(Options options) {
    Option opt = new Option("g", "consumerGroup", true, "consumer group name");
    opt.setRequired(true);//from   ww w .ja  va  2 s  . c o m
    options.addOption(opt);

    return options;
}

From source file:kieker.tools.KaxRun.java

@Override
protected void addAdditionalOptions(final Options options) {
    final Option inputOption = new Option("i", "input", true, "the analysis project file (.kax) loaded");
    inputOption.setArgName("filename");

    options.addOption(inputOption);//w w  w  .j av a2  s  . c  o  m
}

From source file:com.alibaba.rocketmq.tools.command.topic.UpdateTopicPermSubCommand.java

@Override
public Options buildCommandlineOptions(Options options) {
    Option opt = new Option("b", "brokerAddr", true, "create topic to which broker");
    opt.setRequired(false);//from   w w  w.j ava  2  s . c o  m
    options.addOption(opt);

    opt = new Option("c", "clusterName", true, "create topic to which cluster");
    opt.setRequired(false);
    options.addOption(opt);

    opt = new Option("t", "topic", true, "topic name");
    opt.setRequired(true);
    options.addOption(opt);

    opt = new Option("p", "perm", true, "set topic's permission(2|4|6), intro[2:R; 4:W; 6:RW]");
    opt.setRequired(true);
    options.addOption(opt);

    return options;
}

From source file:com.ict.dtube.tools.command.message.QueryMsgByIdSubCommand.java

@Override
public Options buildCommandlineOptions(Options options) {
    Option opt = new Option("i", "msgId", true, "Message Id");
    opt.setRequired(true);/*from w  w w.j  a v  a 2s  .  com*/
    options.addOption(opt);

    return options;
}

From source file:com.netscape.cmstools.user.UserCertAddCLI.java

public void createOptions() {
    Option option = new Option(null, "input", true, "Input file");
    option.setArgName("file");
    options.addOption(option);/*  w  w  w. j  ava2s  .c  o  m*/

    option = new Option(null, "serial", true, "Serial number of certificate in CA");
    option.setArgName("serial number");
    options.addOption(option);
}

From source file:edu.mit.csail.sdg.alloy4.Terminal.java

/**
 * @param args// ww w .  j ava2s. c o m
 * @throws Exception
 */
public static int execute(String[] args) throws Exception {
    // create the command line parser
    CommandLineParser parser = new PosixParser();

    // create the Options
    Options optionsArg = new Options();
    Option helpOpt = new Option("?", "help", false, "print this message");
    Option alloyOpt = new Option("alloy", true, "the alloy input file to check");
    alloyOpt.setRequired(true);
    Option commandOpt = new Option("c", "command", true, "the command to run");
    Option runAllCommandsOpt = new Option("a", "runall", false, "run all commands");
    Option keepResultsOpt = new Option("k", "keep", false, "keep result files");
    Option solverOpt = new Option("s", "solver", true,
            "name of SAT Solver. Options are: " + getAvaliableSatSolvers());

    optionsArg.addOption(helpOpt);
    optionsArg.addOption(alloyOpt);
    optionsArg.addOption(commandOpt);
    optionsArg.addOption(runAllCommandsOpt);
    optionsArg.addOption(keepResultsOpt);
    optionsArg.addOption(solverOpt);

    CommandLine line = null;
    try {
        // parse the command line arguments
        line = parser.parse(optionsArg, args);

        if (line.hasOption(helpOpt.getOpt())) {
            // automatically generate the help statement
            HelpFormatter formatter = new HelpFormatter();
            formatter.printHelp("vdm2alloy", optionsArg);
            return 0;
        }

    } catch (ParseException exp) {
        System.err.println("Unexpected exception:" + exp.getMessage());
        HelpFormatter formatter = new HelpFormatter();
        formatter.printHelp("vdm2alloy", optionsArg);
        return 1;
    }

    String intputAlloyModel = null;
    if (line.hasOption(alloyOpt.getOpt())) {
        intputAlloyModel = line.getOptionValue(alloyOpt.getOpt());
    }

    // Setup solver and alloy libs
    copyFromJAR();

    A4Reporter rep = new A4Reporter();

    A4Options options = new A4Options();

    options.solver = A4Options.SatSolver.MiniSatProverJNI;
    if (line.hasOption(solverOpt.getOpt())) {
        String solverName = line.getOptionValue(solverOpt.getOpt());
        A4Options.SatSolver solver = getSolver(solverName);
        if (solver == null) {
            System.err.println("Solver could not be resolved with value: " + solverName);
            return 1;
        }
        options.solver = solver;
    }

    Module someWorld = null;
    try {
        someWorld = CompUtil.parseEverything_fromFile(rep, null, intputAlloyModel);
        System.out.println();
    } catch (Err e) {
        System.err.println(e);
        System.err.println();
        System.err.flush();
        return 1;
    }

    List<Command> commandsToRun = new Vector<Command>();

    if (line.hasOption(commandOpt.getOpt())) {
        String commandName = line.getOptionValue(commandOpt.getOpt());
        for (Command command : someWorld.getAllCommands()) {
            if (command.label.equals(commandName)) {
                commandsToRun.add(command);
                break;
            }
        }
        if (commandsToRun.isEmpty()) {
            System.err.println("Command: " + commandName + " not found in " + someWorld.getAllCommands());
            return 1;
        }
    }

    if (commandsToRun.isEmpty() || line.hasOption(runAllCommandsOpt.getOpt())) {
        commandsToRun.addAll(someWorld.getAllCommands());
    }

    System.out.println("Alloy Analysis");
    int i = 0;
    for (Command command : commandsToRun) {
        i++;
        A4Solution ans = TranslateAlloyToKodkod.execute_command(rep, someWorld.getAllReachableSigs(), command,
                options);
        show(ans, commandsToRun, command, i);

        if (line.hasOption(keepResultsOpt.getOpt())) {
            final String tempdir = alloyHome() + fs + "binary" + File.separatorChar;
            if (ans.satisfiable()) {
                ans.writeXML(tempdir + "tmp" + i + "cnf.xml");
            }
            final File tempCNF = new File(tempdir + "tmp.cnf");
            copyFile(tempCNF, new File(tempdir + "tmp" + i + ".cnf"));
        }
    }
    System.out.println("Done.");
    return 0;
}

From source file:com.netscape.cmstools.system.KRAConnectorAddCLI.java

public void createOptions() {
    Option option = new Option(null, "host", true, "KRA host");
    option.setArgName("host");
    options.addOption(option);//from  w w  w . j  av a2  s . co  m

    option = new Option(null, "port", true, "KRA port");
    option.setArgName("port");
    options.addOption(option);

    option = new Option(null, "input-file", true, "Input file");
    option.setArgName("input-file");
    options.addOption(option);
}

From source file:com.alibaba.rocketmq.tools.command.connection.ConnectionSubCommand.java

@Override
public Options buildCommandlineOptions(Options options) {
    Option opt = new Option("p", "producerGroup", true, "producer group name");
    opt.setRequired(false);//from   www  .  jav a  2 s.  com
    options.addOption(opt);

    opt = new Option("c", "consumerGroup", true, "consumer group name");
    opt.setRequired(false);
    options.addOption(opt);

    // topic
    opt = new Option("t", "topic", true, "topic name");
    opt.setRequired(false);
    options.addOption(opt);

    return options;
}