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

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

Introduction

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

Prototype

public String[] getOptionValues(char opt) 

Source Link

Document

Retrieves the array of values, if any, of an option.

Usage

From source file:eu.stratosphere.pact.client.CliFrontend.java

/**
 * Executes the info action./*w w w .  j  a  va  2  s  .  c o m*/
 * 
 * @param args Command line arguments for the info action. 
 */
private void info(String[] args) {

    File jarFile = null;
    String assemblerClass = null;
    String[] programArgs = null;

    boolean description;
    boolean plan;

    // Parse command line options
    CommandLine line = null;
    try {
        line = parser.parse(this.options.get(ACTION_INFO), args, false);
    } catch (Exception e) {
        handleError(e);
    }

    // Get jar file
    if (line.hasOption(JAR_OPTION.getOpt())) {
        jarFile = new File(line.getOptionValue(JAR_OPTION.getOpt()));

        // Check if JAR file exists
        if (!jarFile.exists()) {
            System.err.println("Error: Jar file does not exist.");
            printHelp();
            System.exit(1);
        } else if (!jarFile.isFile()) {
            System.err.println("Error: Jar file is not a file.");
            printHelp();
            System.exit(1);
        }
    } else {
        System.err.println("Error: Jar file is not set.");
        printHelp();
        System.exit(1);
    }

    // Get assembler class
    if (line.hasOption(CLASS_OPTION.getOpt())) {
        assemblerClass = line.getOptionValue(CLASS_OPTION.getOpt());
    }

    // get program arguments
    if (line.hasOption(ARGS_OPTION.getOpt())) {
        programArgs = line.getOptionValues(ARGS_OPTION.getOpt());
    }

    description = line.hasOption(DESCR_OPTION.getOpt());
    plan = line.hasOption(PLAN_OPTION.getOpt());

    if (!description && !plan) {
        System.err.println("ERROR: Specify the information to display.");
        printHelp();
        System.exit(1);
    }

    // Try to get load plan
    PactProgram program = null;
    try {
        if (assemblerClass == null) {
            program = new PactProgram(jarFile, programArgs);
        } else {
            program = new PactProgram(jarFile, assemblerClass, programArgs);
        }
    } catch (ProgramInvocationException e) {
        handleError(e);
    }

    // check for description request
    if (description) {
        String descr = null;
        try {
            descr = program.getTextDescription();
        } catch (Exception e) {
            handleError(e);
        }

        if (descr != null) {
            System.out.println("------------------ PACT Program Description ------------------");
            System.out.println(descr);
            System.out.println("--------------------------------------------------------------");
        } else {
            System.err.println("No description available for this plan.");
        }
    }

    // check for json plan request
    if (plan) {
        String jsonPlan = null;

        Configuration configuration = getConfiguration();
        Client client = new Client(configuration);
        try {
            jsonPlan = client.getOptimizerPlanAsJSON(program);
        } catch (ProgramInvocationException e) {
            handleError(e);
        } catch (ErrorInPlanAssemblerException e) {
            handleError(e);
        }

        if (jsonPlan != null) {
            System.out.println("-------------------- PACT Execution Plan ---------------------");
            System.out.println(jsonPlan);
            System.out.println("--------------------------------------------------------------");
        } else {
            System.err.println("JSON plan could not be compiled.");
        }
    }

}

From source file:eu.stratosphere.pact.client.CliFrontend.java

/**
 * Executions the run action.//w ww.j a  va  2 s. co m
 * 
 * @param args Command line arguments for the run action.
 */
private void run(String[] args) {

    File jarFile = null;
    String assemblerClass = null;
    String[] programArgs = null;
    boolean wait = false;

    // Parse command line options
    CommandLine line = null;
    try {
        line = parser.parse(this.options.get(ACTION_RUN), args, false);
    } catch (Exception e) {
        handleError(e);
    }

    // Get jar file
    if (line.hasOption(JAR_OPTION.getOpt())) {
        String jarFilePath = line.getOptionValue(JAR_OPTION.getOpt());
        jarFile = new File(jarFilePath);

        // Check if JAR file exists
        if (!jarFile.exists()) {
            System.err.println("Error: Jar file does not exist.");
            printHelp();
            System.exit(1);
        } else if (!jarFile.isFile()) {
            System.err.println("Error: Jar file is not a file.");
            printHelp();
            System.exit(1);
        }
    } else {
        System.err.println("Error: Jar file is not set.");
        printHelp();
        System.exit(1);
    }

    // Get assembler class
    if (line.hasOption(CLASS_OPTION.getOpt())) {
        assemblerClass = line.getOptionValue(CLASS_OPTION.getOpt());
    }

    // get program arguments
    if (line.hasOption(ARGS_OPTION.getOpt())) {
        programArgs = line.getOptionValues(ARGS_OPTION.getOpt());
    }

    // get wait flag
    wait = line.hasOption(WAIT_OPTION.getOpt());

    // Try to get load plan
    PactProgram program = null;
    try {
        if (assemblerClass == null) {
            program = new PactProgram(jarFile, programArgs);
        } else {
            program = new PactProgram(jarFile, assemblerClass, programArgs);
        }
    } catch (ProgramInvocationException e) {
        handleError(e);
    }

    Configuration configuration = getConfiguration();
    Client client = new Client(configuration);
    try {
        client.run(program, wait);
    } catch (ProgramInvocationException e) {
        handleError(e);
    } catch (ErrorInPlanAssemblerException e) {
        handleError(e);
    }

    System.out.println("Job successfully submitted");

}

From source file:edu.cornell.med.icb.geo.tools.Affy2InsightfulMiner.java

private void proccess(final String[] args) {
    // create the Options
    final Options options = new Options();

    // help//w  w w  . j av a 2 s.c o  m
    options.addOption("h", "help", false, "print this message");

    // input file name
    final Option inputOption = new Option("il", "input-list", true,
            "specify the name of the input file list. This file tab-separated with two columns. Each row must indicate: (1) filename for an Affymetrix text file for one sample, (2) sample ID.");
    inputOption.setArgName("input-file-list");
    inputOption.setRequired(true);
    options.addOption(inputOption);

    // output file name
    final Option outputOption = new Option("o", "output", true, "specify the destination file");
    outputOption.setArgName("file");
    outputOption.setRequired(true);
    options.addOption(outputOption);
    // label values
    final Option labelOptions = new Option("cl", "class-label", true,
            "specify how to set the label of samples");
    labelOptions.setArgName("attribute,value,label");
    labelOptions.setRequired(false);
    options.addOption(labelOptions);

    // group file names
    final Option groupOptions = new Option("sa", "sample-attributes", true,
            "specify a file that associates attributes to samples. The file is tab delimited. The first column of this file is the the sample ID. Additional columns indicate the value of the attributes named in the first line (name of sample ID is can be arbitrary and will be ignored).");
    groupOptions.setArgName("file");
    groupOptions.setRequired(false);
    options.addOption(groupOptions);

    // default label value
    final Option defaultLabelOption = new Option("dl", "default-label", true,
            "Specify the label to use for columns that are not identified by -l -g pairs. Default value is zero.");
    groupOptions.setArgName("double-value");
    groupOptions.setRequired(false);

    // platform description
    final Option platformDescriptionFileOption = new Option("pd", "platform-description", true,
            "The platform description is a GEO platform description file that is used to link probe set ids to genbank identifiers. When a platform description file is provided, the second column in the output will contain the desired indentifier (default genbank).");
    groupOptions.setArgName("file");
    groupOptions.setRequired(false);
    options.addOption(platformDescriptionFileOption);

    // parse the command line arguments
    CommandLine line = null;
    double defaultLabelValue = 0;
    try {
        // create the command line parser
        final CommandLineParser parser = new BasicParser();
        line = parser.parse(options, args, true);
        if ((line.hasOption("cl") && !line.hasOption("sa"))
                || (line.hasOption("sa") && !line.hasOption("cl"))) {
            System.err.println("Options -class-label and -sample-attributes must be used together.");
            System.exit(10);
        }

        if (line.hasOption("dl")) {
            defaultLabelValue = Double.parseDouble(line.getOptionValue("dl"));
        }

    } catch (ParseException e) {
        System.err.println(e.getMessage());
        usage(options);
        System.exit(1);
    }
    // print help and exit
    if (line.hasOption("h")) {
        usage(options);
        System.exit(0);
    }
    try {
        readInputList(line.getOptionValue("il"));
        readSampleAttributes(line.getOptionValue("sa"));
        final String platformFilename = line.getOptionValue("pd");
        System.out.println("Reading platformFileContent description file " + platformFilename);
        platform = new GEOPlatform();
        platform.read(platformFilename);
        System.out.println("Successfully read " + platform.getProbesetCount()
                + " probe set -> secondary identifier pairs.");

        readAndAssembleSamples(line.getOptionValues("cl"), defaultLabelValue, line.getOptionValue("o"));

        System.exit(0);
    } catch (Exception e) {
        e.printStackTrace();
        System.exit(10);
    }
}

From source file:com.eviware.loadui.launcher.LoadUICommandLineLauncher.java

@Override
protected void processCommandLine(CommandLine cmd) {
    try (InputStream is = getClass().getResourceAsStream("/packages-extra.txt")) {
        if (is != null) {
            StringBuilder out = new StringBuilder();
            byte[] b = new byte[4096];
            for (int n; (n = is.read(b)) != -1;)
                out.append(new String(b, 0, n));

            String extra = configProps.getProperty(ORG_OSGI_FRAMEWORK_SYSTEM_PACKAGES_EXTRA, "");
            if (!extra.isEmpty())
                out.append(",").append(extra);

            configProps.setProperty(ORG_OSGI_FRAMEWORK_SYSTEM_PACKAGES_EXTRA, out.toString());
        }/*from w  w  w .j a v  a 2s.  c o m*/
    } catch (IOException e) {
        e.printStackTrace();
    }

    Map<String, Object> attributes = new HashMap<>();

    if (cmd.hasOption(PROJECT_OPTION)) {
        attributes.put("workspaceFile",
                cmd.hasOption(WORKSPACE_OPTION) ? new File(cmd.getOptionValue(WORKSPACE_OPTION)) : null);
        attributes.put("projectFile",
                cmd.hasOption(PROJECT_OPTION) ? new File(cmd.getOptionValue(PROJECT_OPTION)) : null);
        attributes.put("testCase", cmd.getOptionValue(TESTCASE_OPTION));
        if (cmd.getOptionValue(VU_SCENARIO_OPTION) != null)
            attributes.put("testCase", cmd.getOptionValue(VU_SCENARIO_OPTION));
        attributes.put("limits",
                cmd.hasOption(LIMITS_OPTION) ? cmd.getOptionValue(LIMITS_OPTION).split(":") : null);
        attributes.put("localMode", cmd.hasOption(LOCAL_OPTION));
        Map<String, String[]> agents = null;
        if (cmd.hasOption(AGENT_OPTION)) {
            agents = new HashMap<>();
            for (String option : cmd.getOptionValues(AGENT_OPTION)) {
                int ix = option.indexOf("=");
                if (ix != -1)
                    agents.put(option.substring(0, ix), option.substring(ix + 1).split(","));
                else
                    agents.put(option, null);
            }
        }
        attributes.put("agents", agents);

        attributes.put("reportFolder", cmd.getOptionValue(REPORT_DIR_OPTION));
        attributes.put("reportFormat",
                cmd.hasOption(REPORT_FORMAT_OPTION) ? cmd.getOptionValue(REPORT_FORMAT_OPTION) : "PDF");

        List<String> statisticPages = null;
        if (cmd.hasOption(STATISTICS_REPORT_OPTION)) {
            String[] optionValues = cmd.getOptionValues(STATISTICS_REPORT_OPTION);
            statisticPages = optionValues == null ? Collections.<String>emptyList()
                    : Arrays.asList(optionValues);
        }
        attributes.put("statisticPages", statisticPages);
        attributes.put("compare", cmd.getOptionValue(STATISTICS_REPORT_COMPARE_OPTION));

        attributes.put("abort", cmd.getOptionValue(ABORT_ONGOING_REQUESTS_OPTION));

        attributes.put("includeSummary", cmd.hasOption(STATISTICS_REPORT_INCLUDE_SUMMARY_OPTION));

        attributes.put("retainZoom", cmd.hasOption(RETAIN_SAVED_ZOOM_LEVELS));

        command = new ResourceGroovyCommand("/RunTest.groovy", attributes);
    } else if (cmd.hasOption(FILE_OPTION)) {
        command = new FileGroovyCommand(new File(cmd.getOptionValue(FILE_OPTION)), attributes);
    } else {
        printUsageAndQuit();
    }
}

From source file:knowledgeMiner.preprocessing.KnowledgeMinerPreprocessor.java

public void run(CommandLine parse) {
    // Sort out article and heuristics
    ENABLE_PREPROCESSING = true;//from w  ww.ja  v  a 2  s.co  m
    startTime_ = System.currentTimeMillis();
    overwriteMode_ = parse.hasOption("f");
    numWritten_ = 0;
    ConceptModule cm = null;
    boolean reverseOrder = false;
    if (parse.getOptionValue("i") != null) {
        int i = Integer.parseInt(parse.getOptionValue("i"));
        if (parse.hasOption("o"))
            cm = new ConceptModule(new OntologyConcept(i));
        else
            cm = new ConceptModule(i);
    }
    if (parse.hasOption("R"))
        reverseOrder = true;

    PrecomputationTaskType taskType = null;
    if (parse.hasOption("m")) {
        // Mining article
        heuristics_ = new ArrayList<>(miner_.getMiningHeuristics());
        taskType = PrecomputationTaskType.MINE;
    } else if (parse.hasOption("w")) {
        // Mapping article to concept
        heuristics_ = new ArrayList<>(mapper_.getWikiToCycMappingSuite().getHeuristics());
        taskType = PrecomputationTaskType.WIKI_TO_CYC;
    } else if (parse.hasOption("o")) {
        // Mapping concept to article
        heuristics_ = new ArrayList<>(mapper_.getCycToWikiMappingSuite().getHeuristics());
        taskType = PrecomputationTaskType.CYC_TO_WIKI;
    }

    // Parse the heuristics
    if (parse.hasOption("h")) {
        String[] heuristicArgs = parse.getOptionValues("h");
        Collection<WeightedHeuristic> filteredHeuristics = new ArrayList<>();
        // Find the heuristic by name
        for (String arg : heuristicArgs) {
            boolean found = false;
            for (WeightedHeuristic obj : heuristics_) {
                if (arg.equals(obj.getHeuristicName())) {
                    filteredHeuristics.add(obj);
                    found = true;
                    break;
                }
            }

            if (!found) {
                System.err.println("Could not find heuristic: " + arg);
                System.err.println("Available heuristics: " + heuristics_.toString());
                System.exit(1);
            }
        }

        heuristics_ = filteredHeuristics;
    }
    System.out.println("Beginning precomputation with heuristics: " + heuristics_);
    precomputeData(cm, heuristics_, taskType, reverseOrder);

    // Write files
    writeHeuristics();

    long elapsedTime = System.currentTimeMillis() - startTime_;
    System.out.println("\n\nProcessing complete. " + UtilityMethods.toTimeFormat(elapsedTime) + " runtime.");
}

From source file:com.google.enterprise.connector.persist.MigrateStore.java

@Override
public void run(CommandLine commandLine) throws Exception {
    initStandAloneContext(false);//from   w  ww .j  a  v a 2s . c  o m
    // Since we did not start the Context, we need to init TypeMap
    // for PersistentStores to function correctly.
    getTypeMap().init();

    try {
        // If user asks for a list of available PersitentStores,
        // print it and exit.
        if (commandLine.hasOption("list")) {
            listStores();
            return;
        }

        // Get then names of the source and destination PersitentStores.
        String sourceName = null;
        String destName = null;
        String[] args = commandLine.getArgs();
        if ((args.length == 1) || (args.length > 2)) {
            printUsageAndExit(-1);
        }
        if (args.length == 2) {
            sourceName = args[0];
            destName = args[1];
        } else {
            Collection<String> storeNames = getStoreNames();
            sourceName = selectStoreName("source", storeNames);
            if (sourceName == null) {
                return;
            }
            storeNames.remove(sourceName);
            destName = selectStoreName("destination", storeNames);
            if (destName == null) {
                return;
            }
        }
        if (sourceName.equals(destName)) {
            System.err.println("Source and destination PersistentStores must be different.");
            return;
        }

        PersistentStore sourceStore = getPersistentStoreByName(sourceName);

        // Determine which connectors to migrate.
        Collection<String> connectors = null;
        String[] connectorNames = commandLine.getOptionValues('c');
        if (connectorNames != null) {
            connectors = ImmutableSortedSet.copyOf(connectorNames);
        } else if (args.length != 2) {
            // If no connectors were specified on the command line, and we had
            // to prompt the user for the source and destination stores, then also
            // prompt the user for a connector to migrate.
            String name = selectConnectorName(getConnectorNames(sourceStore));
            if (name != null) {
                connectors = ImmutableSortedSet.of(name);
            }
        }

        // Actually perform the migration.
        PersistentStore destStore = getPersistentStoreByName(destName);
        if (sourceStore != null && destStore != null) {
            // Adjust the logging levels so that StoreMigrator messages are logged
            // to the Console.
            Logger.getLogger(StoreMigrator.class.getName()).setLevel(Level.INFO);
            StoreMigrator.migrate(sourceStore, destStore, connectors, commandLine.hasOption("force"));
            StoreMigrator.checkMissing(destStore, connectors);
        }
    } finally {
        shutdown();
    }
}

From source file:com.eviware.soapui.tools.SoapUITestCaseRunner.java

@Override
protected boolean processCommandLine(CommandLine cmd) {
    String message = "";
    if (cmd.hasOption("e"))
        setEndpoint(cmd.getOptionValue("e"));

    if (cmd.hasOption("s")) {
        String testSuite = getCommandLineOptionSubstSpace(cmd, "s");
        setTestSuite(testSuite);/*w  w w  .  j ava2  s .c o  m*/
    }

    if (cmd.hasOption("c")) {
        String testCase = getCommandLineOptionSubstSpace(cmd, "c");
        setTestCase(testCase);
    }

    if (cmd.hasOption("u"))
        setUsername(cmd.getOptionValue("u"));

    if (cmd.hasOption("p"))
        setPassword(cmd.getOptionValue("p"));

    if (cmd.hasOption("w"))
        setWssPasswordType(cmd.getOptionValue("w"));

    if (cmd.hasOption("d"))
        setDomain(cmd.getOptionValue("d"));

    if (cmd.hasOption("h"))
        setHost(cmd.getOptionValue("h"));

    if (cmd.hasOption("f"))
        setOutputFolder(getCommandLineOptionSubstSpace(cmd, "f"));

    if (cmd.hasOption("t"))
        setSettingsFile(getCommandLineOptionSubstSpace(cmd, "t"));

    if (cmd.hasOption("x")) {
        setProjectPassword(cmd.getOptionValue("x"));
    }

    if (cmd.hasOption("v")) {
        setSoapUISettingsPassword(cmd.getOptionValue("v"));
    }

    if (cmd.hasOption("D")) {
        setSystemProperties(cmd.getOptionValues("D"));
    }

    if (cmd.hasOption("G")) {
        setGlobalProperties(cmd.getOptionValues("G"));
    }

    if (cmd.hasOption("P")) {
        setProjectProperties(cmd.getOptionValues("P"));
    }

    setIgnoreError(cmd.hasOption("I"));
    setEnableUI(cmd.hasOption("i"));
    setPrintReport(cmd.hasOption("r"));
    setPrintAlertSiteReport(cmd.hasOption("M"));
    setExportAll(cmd.hasOption("a"));

    if (cmd.hasOption("A")) {
        setExportAll(true);
        System.setProperty(SOAPUI_EXPORT_SEPARATOR, File.separator);
    }

    setJUnitReport(cmd.hasOption("j"));

    if (cmd.hasOption("m"))
        setMaxErrors(Integer.parseInt(cmd.getOptionValue("m")));

    setSaveAfterRun(cmd.hasOption("S"));

    if (message.length() > 0) {
        log.error(message);
        return false;
    }

    return true;
}

From source file:com.aliyun.odps.mapred.bridge.streaming.StreamJob.java

void parseArgv() {
    CommandLine cmdLine = null;
    try {//w  w w.j ava2s . c  o m
        cmdLine = parser.parse(allOptions, argv_);
    } catch (Exception oe) {
        LOG.error(oe.getMessage());
        exitUsage(argv_.length > 0 && "-info".equals(argv_[0]));
    }

    if (cmdLine == null) {
        exitUsage(argv_.length > 0 && "-info".equals(argv_[0]));
        return;
    }

    @SuppressWarnings("unchecked")
    List<String> args = cmdLine.getArgList();
    if (args != null && args.size() > 0) {
        fail("Found " + args.size() + " unexpected arguments on the " + "command line " + args);
    }

    detailedUsage_ = cmdLine.hasOption("info");
    if (cmdLine.hasOption("help") || detailedUsage_) {
        printUsage = true;
        return;
    }
    verbose_ = cmdLine.hasOption("verbose");
    background_ = cmdLine.hasOption("background");
    debug_ = cmdLine.hasOption("debug") ? debug_ + 1 : debug_;

    output_ = cmdLine.getOptionValue("output");

    comCmd_ = cmdLine.getOptionValue("combiner");
    redCmd_ = cmdLine.getOptionValue("reducer");

    lazyOutput_ = cmdLine.hasOption("lazyOutput");

    String[] values = cmdLine.getOptionValues("file");
    SessionState ss = SessionState.get();
    MetaExplorer metaExplorer = new MetaExplorerImpl(ss.getOdps());
    Map<String, String> aliasToTempResource = new HashMap<String, String>();
    String padding = "_" + UUID.randomUUID().toString();
    if (values != null && values.length > 0) {
        for (int i = 0; i < values.length; i++) {
            String file = values[i];
            packageFiles_.add(file);
            try {
                aliasToTempResource.put(FilenameUtils.getName(file),
                        metaExplorer.addFileResourceWithRetry(file, Resource.Type.FILE, padding, true));
            } catch (OdpsException e) {
                throw new RuntimeException(e);
            }
        }

        config_.set("stream.temp.resource.alias", JSON.toJSONString(aliasToTempResource));

        String[] res = config_.getResources();
        Set<String> resources = aliasToTempResource.keySet();
        if (res != null) {
            config_.setResources(StringUtils.join(res, ",") + "," + StringUtils.join(resources, ","));
        } else {
            config_.setResources(StringUtils.join(resources, ","));
        }
    }

    additionalConfSpec_ = cmdLine.getOptionValue("additionalconfspec");
    numReduceTasksSpec_ = cmdLine.getOptionValue("numReduceTasks");
    partitionerSpec_ = cmdLine.getOptionValue("partitioner");
    mapDebugSpec_ = cmdLine.getOptionValue("mapdebug");
    reduceDebugSpec_ = cmdLine.getOptionValue("reducedebug");
    ioSpec_ = cmdLine.getOptionValue("io");

    String[] car = cmdLine.getOptionValues("cacheArchive");
    if (null != car) {
        fail("no -cacheArchive option any more, please use -resources instead.");
    }

    String[] caf = cmdLine.getOptionValues("cacheFile");
    if (null != caf) {
        fail("no -cacheFile option any more, please use -resources instead.");
    }

    mapCmd_ = cmdLine.getOptionValue("mapper");

    String[] cmd = cmdLine.getOptionValues("cmdenv");
    if (null != cmd && cmd.length > 0) {
        for (String s : cmd) {
            if (addTaskEnvironment_.length() > 0) {
                addTaskEnvironment_ += " ";
            }
            addTaskEnvironment_ += s;
        }
    }

    // per table input config
    Map<String, Map<String, String>> inputConfigs = new HashMap<String, Map<String, String>>();
    String[] columns = null;

    for (Option opt : cmdLine.getOptions()) {
        if ("jobconf".equals(opt.getOpt())) {
            String[] jobconf = opt.getValues();
            if (null != jobconf && jobconf.length > 0) {
                for (String s : jobconf) {
                    String[] parts = s.split("=", 2);
                    config_.set(parts[0], parts[1]);
                }
            }
        } else if ("columns".equals(opt.getOpt())) {
            String columnsValue = opt.getValue();
            if (columnsValue.equals("ALL")) {
                columns = null;
            } else {
                columns = columnsValue.split(",");
            }
        } else if ("input".equals(opt.getOpt())) {
            values = opt.getValues();
            if (values != null && values.length > 0) {
                for (String input : values) {
                    TableInfo ti = parseTableInfo(input);
                    if (columns != null) {
                        ti.setCols(columns);
                    }
                    inputSpecs_.add(ti);

                    String inputKey = (ti.getProjectName() + "." + ti.getTableName()).toLowerCase();
                    // XXX only apply once per table
                    if (inputConfigs.get(inputKey) != null) {
                        continue;
                    }

                    Map<String, String> inputConfig = new HashMap<String, String>();
                    inputConfig.put("stream.map.input.field.separator",
                            config_.get("stream.map.input.field.separator", "\t"));
                    // TODO other per table input config: cols, etc.
                    inputConfigs.put(inputKey, inputConfig);
                }
            }
        }
    }
    try {
        config_.set("stream.map.input.configs", JSON.toJSONString(inputConfigs));
    } catch (Exception e) {
        throw new RuntimeException("fail to set input configs");
    }
}

From source file:fr.ens.biologie.genomique.eoulsan.Main.java

/**
 * Parse the options of the command line
 * @return the number of options argument in the command line
 *///from   w  w  w .  j a v a2  s.com
private int parseCommandLine() {

    final Options options = makeOptions();
    final CommandLineParser parser = new GnuParser();
    final String[] argsArray = this.args.toArray(new String[this.args.size()]);

    int argsOptions = 0;

    try {

        // parse the command line arguments
        final CommandLine line = parser.parse(options, argsArray, true);

        // Help option
        if (line.hasOption("help")) {
            help(options);
        }

        // About option
        if (line.hasOption("about")) {
            Common.showMessageAndExit(Globals.ABOUT_TXT);
        }

        // Version option
        if (line.hasOption("version")) {
            Common.showMessageAndExit(Globals.WELCOME_MSG);
        }

        // Licence option
        if (line.hasOption("license")) {
            Common.showMessageAndExit(Globals.LICENSE_TXT);
        }

        // Set Log file
        if (line.hasOption("log")) {

            argsOptions += 2;
            this.logFile = line.getOptionValue("log");
        }

        // Set log level
        if (line.hasOption("loglevel")) {

            argsOptions += 2;
            this.logLevel = line.getOptionValue("loglevel");
        }

        // Set the configuration file
        if (line.hasOption("conf")) {

            argsOptions += 2;
            this.conf = line.getOptionValue("conf");
        }

        // Set the configuration settings
        if (line.hasOption('s')) {

            this.commandLineSettings = Arrays.asList(line.getOptionValues('s'));
            argsOptions += 2 * this.commandLineSettings.size();
        }

        // eoulsan.sh options
        if (line.hasOption('j')) {
            argsOptions += 2;
        }
        if (line.hasOption('m')) {
            argsOptions += 2;
        }
        if (line.hasOption('J')) {
            argsOptions += 2;
        }
        if (line.hasOption('p')) {
            argsOptions += 2;
        }
        if (line.hasOption('w')) {
            argsOptions += 2;
        }

    } catch (ParseException e) {
        Common.errorExit(e, "Error while parsing command line arguments: " + e.getMessage());
    }

    // No arguments found
    if (this.args == null || this.args.size() == argsOptions) {

        Common.showErrorMessageAndExit(
                "This program needs one argument." + " Use the -h option to get more information.\n");
    }

    return argsOptions;
}

From source file:com.eviware.soapui.tools.SoapUILoadTestRunner.java

protected boolean processCommandLine(CommandLine cmd) {
    String message = "";

    if (cmd.hasOption("e"))
        setEndpoint(cmd.getOptionValue("e"));

    if (cmd.hasOption("s")) {
        String testSuite = getCommandLineOptionSubstSpace(cmd, "s");
        setTestSuite(testSuite);//from ww w .  java2  s.  c  om
    }

    if (cmd.hasOption("c")) {
        String testCase = cmd.getOptionValue("c");
        setTestCase(testCase);
    }

    if (cmd.hasOption("l"))
        setLoadTest(cmd.getOptionValue("l"));

    if (cmd.hasOption("u"))
        setUsername(cmd.getOptionValue("u"));

    if (cmd.hasOption("p"))
        setPassword(cmd.getOptionValue("p"));

    if (cmd.hasOption("w"))
        setWssPasswordType(cmd.getOptionValue("w"));

    if (cmd.hasOption("d"))
        setDomain(cmd.getOptionValue("d"));

    if (cmd.hasOption("h"))
        setHost(cmd.getOptionValue("h"));

    if (cmd.hasOption("m"))
        setLimit(Integer.parseInt(cmd.getOptionValue("m")));

    if (cmd.hasOption("n"))
        setThreadCount(Integer.parseInt(cmd.getOptionValue("n")));

    if (cmd.hasOption("f"))
        setOutputFolder(getCommandLineOptionSubstSpace(cmd, "f"));

    if (cmd.hasOption("t"))
        setSettingsFile(getCommandLineOptionSubstSpace(cmd, "t"));

    setPrintReport(cmd.hasOption("r"));
    setSaveAfterRun(cmd.hasOption("S"));

    if (cmd.hasOption("x")) {
        setProjectPassword(cmd.getOptionValue("x"));
    }

    if (cmd.hasOption("v")) {
        setSoapUISettingsPassword(cmd.getOptionValue("v"));
    }

    if (cmd.hasOption("D")) {
        setSystemProperties(cmd.getOptionValues("D"));
    }

    if (cmd.hasOption("G")) {
        setGlobalProperties(cmd.getOptionValues("G"));
    }

    if (cmd.hasOption("P")) {
        setProjectProperties(cmd.getOptionValues("P"));
    }

    if (message.length() > 0) {
        log.error(message);
        return false;
    }

    return true;
}