Example usage for org.apache.commons.cli CommandLine getOptionValue

List of usage examples for org.apache.commons.cli CommandLine getOptionValue

Introduction

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

Prototype

public String getOptionValue(char opt) 

Source Link

Document

Retrieve the argument, if any, of this option.

Usage

From source file:captor.app.CaptorCmdline.java

public static void main(String[] args) {
    CommandLine cmdline = processCmdline(args, getOptions());
    String installPath = cmdline.getOptionValue('d');
    CaptorCmdline captor = new CaptorCmdline(installPath);
}

From source file:captor.app.CaptorMMV.java

public static void main(String[] args) {
    CommandLine cmdline = processCmdline(args, getOptions());
    String installPath = cmdline.getOptionValue('d');
    String language = cmdline.getOptionValue('l', "en");
    CaptorGui mmv = new CaptorMMV(installPath, language);
}

From source file:captor.app.CaptorBuilder.java

public static void main(String[] args) {
    CommandLine cmdline = processCmdline(args, getOptions());
    String installPath = cmdline.getOptionValue('d');
    String language = cmdline.getOptionValue('l', "en");
    CaptorGui captor = new CaptorBuilder(installPath, language);
}

From source file:eu.edisonproject.utility.execute.Main.java

public static void main(String args[]) {
    Options options = new Options();
    Option operation = new Option("op", "operation", true,
            "type of operation to perform. " + "To move cached terms from org.mapdb.DB 'm'");
    operation.setRequired(true);//from w w  w .  ja v a 2s  . c  o  m
    options.addOption(operation);

    Option input = new Option("i", "input", true, "input file path");
    input.setRequired(true);
    options.addOption(input);

    String helpmasg = "Usage: \n";
    for (Object obj : options.getOptions()) {
        Option op = (Option) obj;
        helpmasg += op.getOpt() + ", " + op.getLongOpt() + "\t Required: " + op.isRequired() + "\t\t"
                + op.getDescription() + "\n";
    }

    try {
        CommandLineParser parser = new BasicParser();
        CommandLine cmd = parser.parse(options, args);

        switch (cmd.getOptionValue("operation")) {
        case "m":
            DBTools.portTermCache2Hbase(cmd.getOptionValue("input"));
            DBTools.portBabelNetCache2Hbase(cmd.getOptionValue("input"));
            break;
        default:
            System.out.println(helpmasg);
        }

    } catch (Exception ex) {
        Logger.getLogger(Main.class.getName()).log(Level.SEVERE, helpmasg, ex);
    }
}

From source file:com.pinterest.secor.main.TestLogMessageProducerMain.java

public static void main(String[] args) {
    try {//www  .  j a v  a 2 s .c o m
        CommandLine commandLine = parseArgs(args);
        String topic = commandLine.getOptionValue("topic");
        int messages = ((Number) commandLine.getParsedOptionValue("messages")).intValue();
        int producers = ((Number) commandLine.getParsedOptionValue("producers")).intValue();
        String broker = commandLine.getOptionValue("broker");
        String type = commandLine.getOptionValue("type");
        Number timeshiftNumber = ((Number) commandLine.getParsedOptionValue("timeshift"));
        int timeshift = timeshiftNumber == null ? 0 : timeshiftNumber.intValue();
        for (int i = 0; i < producers; ++i) {
            TestLogMessageProducer producer = new TestLogMessageProducer(topic, messages, type, broker,
                    timeshift);
            producer.start();
        }
    } catch (Throwable t) {
        LOG.error("Log message producer failed", t);
        System.exit(1);
    }
}

From source file:com.wipro.ats.bdre.datagen.GeneratorMain.java

public static void main(String[] args) throws Exception {
    CommandLine commandLine = new GeneratorMain().getCommandLine(args, PARAMS_STRUCTURE);
    String processId = commandLine.getOptionValue("sub-process-id");

    GetProperties getProperties = new GetProperties();
    java.util.Properties listForParams = getProperties.getProperties(processId, "table");
    String outputDir = listForParams.getProperty("outputPath");

    String[] params = new String[] { processId, outputDir };
    int res = ToolRunner.run(new Configuration(), new Driver(), params);
    if (res != 0)
        throw new BDREException("Hive Generator error");

}

From source file:com.pinterest.secor.main.ZookeeperClientMain.java

public static void main(String[] args) {
    try {/*from  w  w w  .j a v  a 2s . c o m*/
        CommandLine commandLine = parseArgs(args);
        String command = commandLine.getOptionValue("command");
        if (!command.equals("delete_committed_offsets")) {
            throw new IllegalArgumentException("command has to be one of \"delete_committed_offsets\"");
        }
        SecorConfig config = SecorConfig.load();
        ZookeeperConnector zookeeperConnector = new ZookeeperConnector(config);
        String topic = commandLine.getOptionValue("topic");
        if (commandLine.hasOption("partition")) {
            int partition = ((Number) commandLine.getParsedOptionValue("partition")).intValue();
            TopicPartition topicPartition = new TopicPartition(topic, partition);
            zookeeperConnector.deleteCommittedOffsetPartitionCount(topicPartition);
        } else {
            zookeeperConnector.deleteCommittedOffsetTopicCount(topic);
        }
    } catch (Throwable t) {
        LOG.error("Zookeeper client failed", t);
        System.exit(1);
    }
}

From source file:com.wipro.ats.bdre.dq.DQMain.java

/**
 * @param args//from  www . jav a  2  s .c om
 * @throws Exception
 */
public static void main(String[] args) throws Exception {

    CommandLine commandLine = new DQMain().getCommandLine(args, PARAMS_STRUCTURE);
    String processId = commandLine.getOptionValue("process-id");
    String sPath = commandLine.getOptionValue("source-file-path");
    String destDir = commandLine.getOptionValue("destination-directory");

    int result = 0;
    if (sPath.indexOf(';') != -1 || sPath.indexOf(',') != -1) {
        String[] lof = sPath.split(";");
        String[] entries = lof[0].split(",");
        String[] params = { processId, entries[2], destDir };
        result = ToolRunner.run(new Configuration(), new DQDriver(), params);

    } else {
        String[] params = { processId, sPath, destDir };
        result = ToolRunner.run(new Configuration(), new DQDriver(), params);
    }
    if (result != 0)
        throw new DQValidationException(new DQStats());
}

From source file:com.floreantpos.main.Main.java

/**
 * @param args/*  w w  w . j  av  a 2 s.  c  o m*/
 * @throws Exception 
 */
public static void main(String[] args) throws Exception {
    Options options = new Options();
    options.addOption(DEVELOPMENT_MODE, true, "State if this is developmentMode"); //$NON-NLS-1$
    CommandLineParser parser = new BasicParser();
    CommandLine commandLine = parser.parse(options, args);
    String optionValue = commandLine.getOptionValue(DEVELOPMENT_MODE);
    Locale defaultLocale = TerminalConfig.getDefaultLocale();
    if (defaultLocale != null) {
        Locale.setDefault(defaultLocale);
    }

    Application application = Application.getInstance();

    if (optionValue != null) {
        application.setDevelopmentMode(Boolean.valueOf(optionValue));
    }

    application.start();
}

From source file:azkaban.crypto.EncryptionCLI.java

/**
 * Outputs ciphered text to STDOUT./* w  w  w. java  2s .c o m*/
 *
 * usage: EncryptionCLI [-h] -k <pass phrase> -p <plainText> -v <crypto version>
 * -h,--help                       print this message
 * -k,--key <pass phrase>          Passphrase used for encrypting plain text
 * -p,--plaintext <plainText>      Plaintext that needs to be encrypted
 * -v,--version <crypto version>   Version it will use to encrypt Version: [1.0, 1.1]
 *
 * @param args
 * @throws ParseException
 */
public static void main(String[] args) throws ParseException {
    CommandLineParser parser = new DefaultParser();

    if (parser.parse(createHelpOptions(), args, true).hasOption(HELP_KEY)) {
        new HelpFormatter().printHelp(EncryptionCLI.class.getSimpleName(), createOptions(), true);
        return;
    }

    CommandLine line = parser.parse(createOptions(), args);

    String passphraseKey = line.getOptionValue(PASSPHRASE_KEY);
    String plainText = line.getOptionValue(PLAINTEXT_KEY);
    String version = line.getOptionValue(VERSION_KEY);

    ICrypto crypto = new Crypto();
    String cipheredText = crypto.encrypt(plainText, passphraseKey, Version.fromVerString(version));
    System.out.println(cipheredText);
}