Example usage for org.apache.commons.cli HelpFormatter printHelp

List of usage examples for org.apache.commons.cli HelpFormatter printHelp

Introduction

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

Prototype

public void printHelp(String cmdLineSyntax, Options options) 

Source Link

Document

Print the help for options with the specified command line syntax.

Usage

From source file:com.jones_systems.Tieout.java

public static void main(String[] args) {

    String testFilename = null;/* w  w  w .j  a  v  a  2  s.c  o  m*/

    Options options = new Options();

    //options.addOption("f", "filename", true, "the file to use for the Tieout check");
    Option filename = OptionBuilder.withArgName("filename").hasArg()
            .withDescription("the file name of the XML test file").create("filename");
    options.addOption(filename);

    CommandLineParser parser = new GnuParser();

    try {
        CommandLine line = parser.parse(options, args);

        if (line.hasOption("filename")) {
            testFilename = line.getOptionValue("filename");
        } else {
            HelpFormatter formatter = new HelpFormatter();
            formatter.printHelp("tieout", options);
            System.exit(2);
        }

    } catch (ParseException exp) {

    }

    File testfile = new File(testFilename);

    if (!testfile.exists()) {
        System.err.println("Cannot find file!");
        System.exit(1);
    }

    System.out.println("Starting test with file: " + testFilename);

    Tieout ts = new Tieout(testfile);
    boolean connected = ts.connectDatasources();

    if (!connected) {
        System.err.print("Could not connect to all datasources");
        System.exit(1);
    }

    ts.runTests();

}

From source file:apps.classification.ClassifySVMPerf.java

public static void main(String[] args) throws IOException {

    boolean dumpConfidences = false;

    String cmdLineSyntax = ClassifySVMPerf.class.getName()
            + " [OPTIONS] <path to svm_perf_classify> <testIndexDirectory> <modelDirectory>";

    Options options = new Options();

    OptionBuilder.withArgName("d");
    OptionBuilder.withDescription("Dump confidences file");
    OptionBuilder.withLongOpt("d");
    OptionBuilder.isRequired(false);/*from  w ww  . j  a  v a2  s.  c o m*/
    OptionBuilder.hasArg(false);
    options.addOption(OptionBuilder.create());

    OptionBuilder.withArgName("t");
    OptionBuilder.withDescription("Path for temporary files");
    OptionBuilder.withLongOpt("t");
    OptionBuilder.isRequired(false);
    OptionBuilder.hasArg();
    options.addOption(OptionBuilder.create());

    OptionBuilder.withArgName("v");
    OptionBuilder.withDescription("Verbose output");
    OptionBuilder.withLongOpt("v");
    OptionBuilder.isRequired(false);
    OptionBuilder.hasArg(false);
    options.addOption(OptionBuilder.create());

    OptionBuilder.withArgName("s");
    OptionBuilder.withDescription("Don't delete temporary training file in svm_perf format (default: delete)");
    OptionBuilder.withLongOpt("s");
    OptionBuilder.isRequired(false);
    OptionBuilder.hasArg(false);
    options.addOption(OptionBuilder.create());

    SvmPerfClassifierCustomizer customizer = null;

    GnuParser parser = new GnuParser();
    String[] remainingArgs = null;
    try {
        CommandLine line = parser.parse(options, args);

        remainingArgs = line.getArgs();

        customizer = new SvmPerfClassifierCustomizer(remainingArgs[0]);

        if (line.hasOption("d"))
            dumpConfidences = true;

        if (line.hasOption("v"))
            customizer.printSvmPerfOutput(true);

        if (line.hasOption("s")) {
            customizer.setDeleteTestFiles(false);
            customizer.setDeletePredictionsFiles(false);
        }

        if (line.hasOption("t"))
            customizer.setTempPath(line.getOptionValue("t"));

    } catch (Exception exp) {
        System.err.println("Parsing failed.  Reason: " + exp.getMessage());
        HelpFormatter formatter = new HelpFormatter();
        formatter.printHelp(cmdLineSyntax, options);
        System.exit(-1);
    }

    if (remainingArgs.length != 3) {
        HelpFormatter formatter = new HelpFormatter();
        formatter.printHelp(cmdLineSyntax, options);
        System.exit(-1);
    }

    String testFile = remainingArgs[1];

    File file = new File(testFile);

    String testName = file.getName();
    String testPath = file.getParent();

    String classifierFile = remainingArgs[2];

    file = new File(classifierFile);

    String classifierName = file.getName();
    String classifierPath = file.getParent();
    FileSystemStorageManager storageManager = new FileSystemStorageManager(testPath, false);
    storageManager.open();
    IIndex test = TroveReadWriteHelper.readIndex(storageManager, testName, TroveContentDBType.Full,
            TroveClassificationDBType.Full);
    storageManager.close();

    SvmPerfDataManager dataManager = new SvmPerfDataManager(customizer);
    storageManager = new FileSystemStorageManager(classifierPath, false);
    storageManager.open();
    SvmPerfClassifier classifier = (SvmPerfClassifier) dataManager.read(storageManager, classifierName);
    storageManager.close();

    classifier.setRuntimeCustomizer(customizer);

    // CLASSIFICATION
    String classificationName = testName + "_" + classifierName;

    Classifier classifierModule = new Classifier(test, classifier, dumpConfidences);
    classifierModule.setClassificationMode(ClassificationMode.PER_CATEGORY);
    classifierModule.exec();

    IClassificationDB testClassification = classifierModule.getClassificationDB();

    storageManager = new FileSystemStorageManager(testPath, false);
    storageManager.open();
    TroveReadWriteHelper.writeClassification(storageManager, testClassification, classificationName + ".cla",
            true);
    storageManager.close();

    if (dumpConfidences) {
        ClassificationScoreDB confidences = classifierModule.getConfidences();
        ClassificationScoreDB.write(testPath + Os.pathSeparator() + classificationName + ".confidences",
                confidences);
    }
}

From source file:com.uber.stream.kafka.mirrormaker.controller.ControllerStarter.java

public static void main(String[] args) throws Exception {
    CommandLineParser parser = new DefaultParser();
    CommandLine cmd = null;//  w w w .  java 2  s  .  c om
    cmd = parser.parse(ControllerConf.constructControllerOptions(), args);
    if (cmd.getOptions().length == 0 || cmd.hasOption("help")) {
        HelpFormatter f = new HelpFormatter();
        f.printHelp("OptionsTip", ControllerConf.constructControllerOptions());
        System.exit(0);
    }
    final ControllerStarter controllerStarter = ControllerStarter.init(cmd);

    Runtime.getRuntime().addShutdownHook(new Thread() {
        public void run() {
            try {
                controllerStarter.stop();
            } catch (Exception e) {
                LOGGER.error("Caught error during shutdown! ", e);
            }
        }
    });

    try {
        controllerStarter.start();
    } catch (Exception e) {
        LOGGER.error("Cannot start Helix Mirror Maker Controller: ", e);
    }
}

From source file:gobblin.runtime.util.JobStateToJsonConverter.java

@SuppressWarnings("all")
public static void main(String[] args) throws Exception {
    Option sysConfigOption = Option.builder("sc").argName("system configuration file")
            .desc("Gobblin system configuration file").longOpt("sysconfig").hasArgs().build();
    Option storeUrlOption = Option.builder("u").argName("gobblin state store URL")
            .desc("Gobblin state store root path URL").longOpt("storeurl").hasArgs().required().build();
    Option jobNameOption = Option.builder("n").argName("gobblin job name").desc("Gobblin job name")
            .longOpt("name").hasArgs().required().build();
    Option jobIdOption = Option.builder("i").argName("gobblin job id").desc("Gobblin job id").longOpt("id")
            .hasArgs().build();//w w w  .j  a  va  2s . c o m
    Option convertAllOption = Option.builder("a")
            .desc("Whether to convert all past job states of the given job").longOpt("all").build();
    Option keepConfigOption = Option.builder("kc").desc("Whether to keep all configuration properties")
            .longOpt("keepConfig").build();
    Option outputToFile = Option.builder("t").argName("output file name").desc("Output file name")
            .longOpt("toFile").hasArgs().build();

    Options options = new Options();
    options.addOption(sysConfigOption);
    options.addOption(storeUrlOption);
    options.addOption(jobNameOption);
    options.addOption(jobIdOption);
    options.addOption(convertAllOption);
    options.addOption(keepConfigOption);
    options.addOption(outputToFile);

    CommandLine cmd = null;
    try {
        CommandLineParser parser = new DefaultParser();
        cmd = parser.parse(options, args);
    } catch (ParseException pe) {
        HelpFormatter formatter = new HelpFormatter();
        formatter.printHelp("JobStateToJsonConverter", options);
        System.exit(1);
    }

    Properties sysConfig = new Properties();
    if (cmd.hasOption(sysConfigOption.getLongOpt())) {
        sysConfig = JobConfigurationUtils.fileToProperties(cmd.getOptionValue(sysConfigOption.getLongOpt()));
    }

    JobStateToJsonConverter converter = new JobStateToJsonConverter(sysConfig, cmd.getOptionValue('u'),
            cmd.hasOption("kc"));
    StringWriter stringWriter = new StringWriter();
    if (cmd.hasOption('i')) {
        converter.convert(cmd.getOptionValue('n'), cmd.getOptionValue('i'), stringWriter);
    } else {
        if (cmd.hasOption('a')) {
            converter.convertAll(cmd.getOptionValue('n'), stringWriter);
        } else {
            converter.convert(cmd.getOptionValue('n'), stringWriter);
        }
    }

    if (cmd.hasOption('t')) {
        Closer closer = Closer.create();
        try {
            FileOutputStream fileOutputStream = closer.register(new FileOutputStream(cmd.getOptionValue('t')));
            OutputStreamWriter outputStreamWriter = closer.register(
                    new OutputStreamWriter(fileOutputStream, ConfigurationKeys.DEFAULT_CHARSET_ENCODING));
            BufferedWriter bufferedWriter = closer.register(new BufferedWriter(outputStreamWriter));
            bufferedWriter.write(stringWriter.toString());
        } catch (Throwable t) {
            throw closer.rethrow(t);
        } finally {
            closer.close();
        }
    } else {
        System.out.println(stringWriter.toString());
    }
}

From source file:co.turnus.analysis.partitioning.CommunicationCostPartitioningCli.java

public static void main(String[] args) {
    try {// ww  w  .  j a  va2  s .  c  om
        CommandLineParser parser = new GnuParser();
        CommandLine cmd = parser.parse(cliOptions, args);
        Configuration config = parseCommandLine(cmd);

        // init models
        AnalysisActivator.init();

        // init models
        AnalysisActivator.init();

        // set logger verbosity
        if (config.getBoolean(VERBOSE, false)) {
            TurnusLogger.setLevel(TurnusLevel.ALL);
        }

        // load trace project
        File tDir = new File(config.getString(TRACE_PROJECT));
        TraceProject project = TraceProject.load(tDir);

        CommunicationCostPartitioning ccp = new CommunicationCostPartitioning(project);
        ccp.setConfiguration(config);
        PartitioningData data = ccp.run();

        TurnusLogger.info("Storing results...");
        File outPath = new File(config.getString(OUTPUT_PATH));

        // store the analysis report
        String uuid = UUID.randomUUID().toString();
        File rFile = new File(outPath, uuid + "." + TurnusExtension.REPORT);
        Report report = DataFactory.eINSTANCE.createReport();
        report.setDate(new Date());
        report.setComment("Report with only Communication cost partitioning results analysis");
        report.getDataSet().add(data);
        EcoreHelper.storeEObject(report, new ResourceSetImpl(), rFile);
        TurnusLogger.info("TURNUS report stored in " + rFile);

        // store formatted reports
        String xlsName = config.getString(XLS, "");
        if (!xlsName.isEmpty()) {
            File xlsFile = new File(outPath, xlsName + ".xls");
            new XlsPartitioningDataWriter().write(data, xlsFile);
            TurnusLogger.info("XLS report stored in " + xlsFile);
        }

        String bxdfName = config.getString(XCF, "");
        if (!bxdfName.isEmpty()) {
            File xcfFile = new File(outPath, bxdfName + ".xcf");
            new XmlPartitioningDataWriter().write(data, xcfFile);
            TurnusLogger.info("XCF files (one for each configuration) " + "stored in " + outPath);
        }

        TurnusLogger.info("Analysis Done!");

    } catch (ParseException e) {
        TurnusLogger.error(e.getMessage());
        HelpFormatter formatter = new HelpFormatter();
        formatter.printHelp(CommunicationCostPartitioningCli.class.getSimpleName(), cliOptions);
    } catch (Exception e) {
        TurnusLogger.error(e.getMessage());
    }

}

From source file:com.example.dlp.Metadata.java

/** Retrieve infoTypes. */
public static void main(String[] args) throws Exception {
    Options options = new Options();
    Option languageCodeOption = new Option("language", null, true, "BCP-47 language code");
    languageCodeOption.setRequired(false);
    options.addOption(languageCodeOption);

    Option categoryOption = new Option("category", null, true, "Category of info types to list.");
    categoryOption.setRequired(false);/*  w  w w. j  a va 2s . c  o  m*/
    options.addOption(categoryOption);

    CommandLineParser parser = new DefaultParser();
    HelpFormatter formatter = new HelpFormatter();
    CommandLine cmd;
    try {
        cmd = parser.parse(options, args);
    } catch (ParseException e) {
        System.out.println(e.getMessage());
        formatter.printHelp(Metadata.class.getName(), options);
        System.exit(1);
        return;
    }
    String languageCode = cmd.getOptionValue(languageCodeOption.getOpt(), "en-US");
    if (cmd.hasOption(categoryOption.getOpt())) {
        String category = cmd.getOptionValue(categoryOption.getOpt());
        listInfoTypes(category, languageCode);
    } else {
        listRootCategories(languageCode);
    }
}

From source file:com.genentech.struchk.sdfNormalizer.java

public static void main(String[] args) {
    long start = System.currentTimeMillis();
    int nMessages = 0;
    int nErrors = 0;
    int nStruct = 0;

    // create command line Options object
    Options options = new Options();
    Option opt = new Option("in", true, "input file [.ism,.sdf,...]");
    opt.setRequired(true);//  w  ww  .  j  a  v a 2 s .  c  o  m
    options.addOption(opt);

    opt = new Option("out", true, "output file");
    opt.setRequired(true);
    options.addOption(opt);

    opt = new Option("mol", true, "molFile used for output: ORIGINAL(def)|NORMALIZED|TAUTOMERIC");
    opt.setRequired(false);
    options.addOption(opt);

    opt = new Option("shortMessage", false,
            "Limit message to first 80 characters to conform with sdf file specs.");
    opt.setRequired(false);
    options.addOption(opt);

    CommandLineParser parser = new PosixParser();
    CommandLine cmd;
    try {
        cmd = parser.parse(options, args);
    } catch (ParseException e) {
        exitWithHelp(options, e.getMessage());
        throw new Error(e); // avoid compiler errors
    }
    args = cmd.getArgs();

    if (args.length != 0) {
        System.err.print("Unknown options: " + args + "\n\n");
        HelpFormatter formatter = new HelpFormatter();
        formatter.printHelp("sdfNormalizer", options);
        System.exit(1);
    }

    String molOpt = cmd.getOptionValue("mol");
    OUTMolFormat outMol = OUTMolFormat.ORIGINAL;
    if (molOpt == null || "original".equalsIgnoreCase(molOpt))
        outMol = OUTMolFormat.ORIGINAL;
    else if ("NORMALIZED".equalsIgnoreCase(molOpt))
        outMol = OUTMolFormat.NORMALIZED;
    else if ("TAUTOMERIC".equalsIgnoreCase(molOpt))
        outMol = OUTMolFormat.TAUTOMERIC;
    else {
        System.err.printf("Unkown option for -mol: %s\n", molOpt);
        System.exit(1);
    }

    String inFile = cmd.getOptionValue("in");
    String outFile = cmd.getOptionValue("out");
    boolean limitMessage = cmd.hasOption("shortMessage");

    try {
        oemolistream ifs = new oemolistream(inFile);
        oemolostream ofs = new oemolostream(outFile);

        URL cFile = OEStruchk.getResourceURL(OEStruchk.class, "Struchk.xml");

        // create OEStruchk from config file
        OEStruchk strchk = new OEStruchk(cFile, CHECKConfig.ASSIGNStructFlag, false);

        OEGraphMol mol = new OEGraphMol();
        StringBuilder sb = new StringBuilder(2000);
        while (oechem.OEReadMolecule(ifs, mol)) {
            if (!strchk.applyRules(mol, null))
                nErrors++;

            switch (outMol) {
            case NORMALIZED:
                mol.Clear();
                oechem.OEAddMols(mol, strchk.getTransformedMol("parent"));
                break;
            case TAUTOMERIC:
                mol.Clear();
                oechem.OEAddMols(mol, strchk.getTransformedMol(null));
                break;
            case ORIGINAL:
                break;
            }

            oechem.OESetSDData(mol, "CTISMILES", strchk.getTransformedIsoSmiles(null));
            oechem.OESetSDData(mol, "CTSMILES", strchk.getTransformedSmiles(null));
            oechem.OESetSDData(mol, "CISMILES", strchk.getTransformedIsoSmiles("parent"));
            oechem.OESetSDData(mol, "Strutct_Flag", strchk.getStructureFlag().getName());

            List<Message> msgs = strchk.getStructureMessages(null);
            nMessages += msgs.size();
            for (Message msg : msgs)
                sb.append(String.format("\t%s:%s", msg.getLevel(), msg.getText()));
            if (limitMessage)
                sb.setLength(Math.min(sb.length(), 80));

            oechem.OESetSDData(mol, "NORM_MESSAGE", sb.toString());

            oechem.OEWriteMolecule(ofs, mol);

            sb.setLength(0);
            nStruct++;
        }
        strchk.delete();
        mol.delete();
        ifs.close();
        ifs.delete();
        ofs.close();
        ofs.delete();

    } catch (Exception e) {
        throw new Error(e);
    } finally {
        System.err.printf("sdfNormalizer: Checked %d structures %d errors, %d messages in %dsec\n", nStruct,
                nErrors, nMessages, (System.currentTimeMillis() - start) / 1000);
    }
}

From source file:com.jolbox.benchmark.BenchmarkLaunch.java

/**
 * @param args//  w  ww  .ja  va2  s .  co  m
 * @throws ClassNotFoundException 
 * @throws PropertyVetoException 
 * @throws SQLException 
 * @throws NoSuchMethodException 
 * @throws InvocationTargetException 
 * @throws IllegalAccessException 
 * @throws InterruptedException 
 * @throws SecurityException 
 * @throws IllegalArgumentException 
 * @throws NamingException 
 * @throws ParseException 
 * @throws IOException 
 */
public static void main(String[] args) throws ClassNotFoundException, SQLException, PropertyVetoException,
        IllegalArgumentException, SecurityException, InterruptedException, IllegalAccessException,
        InvocationTargetException, NoSuchMethodException, NamingException, ParseException, IOException {

    Options options = new Options();
    options.addOption("t", "threads", true, "Max number of threads");
    options.addOption("s", "stepping", true, "Stepping of threads");
    options.addOption("p", "poolsize", true, "Pool size");
    options.addOption("h", "help", false, "Help");

    CommandLineParser parser = new PosixParser();
    CommandLine cmd = parser.parse(options, args);
    if (cmd.hasOption("h")) {
        HelpFormatter formatter = new HelpFormatter();
        formatter.printHelp("benchmark.jar", options);
        System.exit(1);
    }

    BenchmarkTests.threads = 400;
    BenchmarkTests.stepping = 5;
    BenchmarkTests.pool_size = 200;
    if (cmd.hasOption("t")) {
        BenchmarkTests.threads = Integer.parseInt(cmd.getOptionValue("t", "400"));
    }
    if (cmd.hasOption("s")) {
        BenchmarkTests.stepping = Integer.parseInt(cmd.getOptionValue("s", "20"));
    }
    if (cmd.hasOption("p")) {
        BenchmarkTests.pool_size = Integer.parseInt(cmd.getOptionValue("p", "200"));
    }

    System.out.println("Starting benchmark tests with " + BenchmarkTests.threads + " threads (stepping "
            + BenchmarkTests.stepping + ") using pool size of " + BenchmarkTests.pool_size + " connections");

    new MockJDBCDriver();
    BenchmarkTests tests = new BenchmarkTests();

    plotLineGraph(tests.testMultiThreadedConstantDelay(0), 0, false);
    plotLineGraph(tests.testMultiThreadedConstantDelay(10), 10, false);
    plotLineGraph(tests.testMultiThreadedConstantDelay(25), 25, false);
    plotLineGraph(tests.testMultiThreadedConstantDelay(50), 50, false);
    plotLineGraph(tests.testMultiThreadedConstantDelay(75), 75, false);

    plotBarGraph("Single Thread", "bonecp-singlethread-poolsize-" + BenchmarkTests.pool_size + "-threads-"
            + BenchmarkTests.threads + ".png", tests.testSingleThread());
    plotBarGraph(
            "Prepared Statement\nSingle Threaded", "bonecp-preparedstatement-single-poolsize-"
                    + BenchmarkTests.pool_size + "-threads-" + BenchmarkTests.threads + ".png",
            tests.testPreparedStatementSingleThread());
    plotLineGraph(tests.testMultiThreadedConstantDelayWithPreparedStatements(0), 0, true);
    plotLineGraph(tests.testMultiThreadedConstantDelayWithPreparedStatements(10), 10, true);
    plotLineGraph(tests.testMultiThreadedConstantDelayWithPreparedStatements(25), 25, true);
    plotLineGraph(tests.testMultiThreadedConstantDelayWithPreparedStatements(50), 50, true);
    plotLineGraph(tests.testMultiThreadedConstantDelayWithPreparedStatements(75), 75, true);

}

From source file:de.jgoestl.massdatagenerator.MassDataGenerator.java

/**
 * @param args the command line arguments
 *//*from www .j a va  2s  .c o  m*/
public static void main(String[] args) {
    // CommandLine options
    Options options = new Options();
    options.addOption("i", "input", true, "The input file");
    options.addOption("o", "output", true, "The output file");
    options.addOption("c", "count", true, "The amount of generatet data");
    options.addOption("d", "dateFormat", true, "A custom date format");
    options.addOption("h", "help", false, "Show this");

    CommandLineParser parser = new GnuParser();
    CommandLine cmd = null;
    try {
        cmd = parser.parse(options, args);
    } catch (ParseException ex) {
        Logger.getLogger(MassDataGenerator.class.getName()).log(Level.SEVERE, null, ex);
        System.exit(1);
    }

    // Show the help
    if (cmd.hasOption("help") || !cmd.hasOption("input") || !cmd.hasOption("output")
            || !cmd.hasOption("count")) {
        HelpFormatter formatter = new HelpFormatter();
        formatter.printHelp("massDataGenerator", options);

        System.out.println("\nFollowing in your input file will be replaced:");
        System.out.println("#UUID# - A random UUID");
        System.out.println("#SEQ#  - A consecutive number (starting with 1)");
        System.out.println("#DATE# - The current date (YYYY-MM-d h:m:s.S)");

        System.exit(0);
    }

    // Get values and validate
    String inputFilePath = cmd.getOptionValue("input");
    String outputPath = cmd.getOptionValue("output");
    int numberOfData = getNumberOfData(cmd);
    validate(inputFilePath, outputPath, numberOfData);
    DateFormat dateFormat = getDateFormat(cmd);

    // Read, generte and write Data
    String inputString = null;
    inputString = readInputFile(inputFilePath, inputString);
    StringBuilder output = generateOutput(numberOfData, inputString, dateFormat);
    writeOutput(outputPath, output);
}

From source file:jp.primecloud.auto.tool.management.main.Main.java

public static void main(String args[]) {
    Options options = new Options();
    options.addOption("Z", false, "Zabbix mode");
    options.addOption("U", false, "UPDATE mode");
    options.addOption("S", false, "SELECT mode");
    options.addOption("C", false, "Create Mode");
    options.addOption("P", false, "Show Platform");
    options.addOption("L", false, "Show Users");
    options.addOption("E", false, "Ecrypt UserPassword");
    options.addOption("I", false, "IaasGateway Mode");
    options.addOption("A", false, "PCC-API Genarate ID or Key Mode");
    options.addOption("W", false, "Decrypt UserPassword");

    options.addOption("username", true, "Create the username");
    options.addOption("password", true, "Create the password");
    options.addOption("firstname", true, "Create the firstname");
    options.addOption("familyname", true, "Create the familyname");
    options.addOption("userno", true, "Create the userno");

    options.addOption("dburl", "connectionurl", true, "PrimeCloud Controller database url");
    options.addOption("dbuser", "username", true, "PrimeCloud Controller database username");
    options.addOption("dbpass", "password", true, "PrimeCloud Controller database password");

    options.addOption("sql", true, "SQL");
    options.addOption("columnname", true, "columnName");
    options.addOption("columntype", true, "columnType");
    options.addOption("salt", true, "Salt");

    OptionBuilder.withLongOpt("prepared");
    OptionBuilder.hasArgs();/*w ww .  j a v a  2 s.  c o  m*/
    OptionBuilder.withDescription("execute as PreparedStatement");
    OptionBuilder.withArgName("params");
    Option optionPrepared = OptionBuilder.create();
    options.addOption(optionPrepared);

    // for Zabbix
    options.addOption("enable", false, "enable");
    options.addOption("disable", false, "disable");
    options.addOption("get", false, "getUser from zabbix");
    options.addOption("check", false, "API setting check for zabbix");

    options.addOption("config", true, "Property can obtain from management-config.properties");
    options.addOption("platformkind", true, "Platform kind. e.g. ec2 and ec2_vpc or vmware");
    options.addOption("platformname", true, "Platform can obtain from auto-config.xml");
    options.addOption("platformno", true, "Platform can obtain from auto-config.xml");

    // for IaasGateway(AWS, Cloudstack)
    options.addOption("keyname", true, "import your key pair as keyName");
    options.addOption("publickey", true, "import your public key");

    // for PCC
    options.addOption("accessid", true, "accessid for PCC-API");
    options.addOption("secretkey", true, "secretkey for PCC-API");
    options.addOption("generatetype", true, "genarateType for PCC-API");

    options.addOption("h", "help", false, "help");

    CommandLineParser parser = new BasicParser();

    CommandLine commandLine;
    try {
        commandLine = parser.parse(options, args);
    } catch (ParseException e) {
        System.out.println(
                "???????? -h?????????");
        return;
    }

    if (commandLine.hasOption("h")) {
        HelpFormatter f = new HelpFormatter();
        f.printHelp("PCC script ", options);
    }

    ManagementConfigLoader.init();
    //?

    //Zabbix?
    if (commandLine.hasOption("Z")) {
        if (commandLine.hasOption("C")) {
            //Zabbix?
            ZabbixMain.createExecute(commandLine);
        } else if (commandLine.hasOption("U")) {
            //Zabbix
            ZabbixMain.updateExecute(commandLine);
        } else if (commandLine.hasOption("disable")) {
            //Zabbix
            ZabbixMain.disableExecute(commandLine);
        } else if (commandLine.hasOption("enable")) {
            //Zabbix
            ZabbixMain.enableExecute(commandLine);
        } else if (commandLine.hasOption("get")) {
            //Zabbix?
            ZabbixMain.getUser(commandLine);
        } else if (commandLine.hasOption("check")) {
            //Zabbix??
            ZabbixMain.checkApiVersion();
        }
        //PCC?
    } else if (commandLine.hasOption("U")) {
        if (commandLine.hasOption("prepared")) {
            SQLMain.updateExecutePrepared(commandLine);
        } else {
            //Update?
            SQLMain.updateExecute(commandLine);
        }
    } else if (commandLine.hasOption("S")) {
        //Select?
        SQLMain.selectExecute(commandLine);
    } else if (commandLine.hasOption("P")) {
        //?
        ConfigMain.showPlatforms();
    } else if (commandLine.hasOption("L")) {
        //PCC?
        UserService.showUserPlatform();
    } else if (commandLine.hasOption("config")) {
        //???
        ConfigMain.getProperty(commandLine.getOptionValue("config"));
    } else if (commandLine.hasOption("platformname") && commandLine.hasOption("platformkind")) {
        //??????
        ConfigMain.getPlatformNo(commandLine.getOptionValue("platformname"),
                commandLine.getOptionValue("platformkind"));
    } else if (commandLine.hasOption("E")) {
        //PCC??
        UserService.encryptUserPassword(commandLine.getOptionValue("password"));
    } else if (commandLine.hasOption("I")) {
        //IaasGatewayCall??AWS or Cloudstack???
        IaasGatewayMain.importExecute(commandLine);
    } else if (commandLine.hasOption("A")) {
        PccApiGenerateService.genarate(commandLine);
    } else if (commandLine.hasOption("W")) {
        //PCC??
        UserService.decryptUserPassword(commandLine.getOptionValue("password"),
                commandLine.getOptionValue("salt"));
    }
}