Example usage for org.apache.commons.cli OptionBuilder isRequired

List of usage examples for org.apache.commons.cli OptionBuilder isRequired

Introduction

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

Prototype

public static OptionBuilder isRequired() 

Source Link

Document

The next Option created will be required.

Usage

From source file:org.schreibubi.JCombinationsTools.generateBinaryDiffValues.GenerateBinaryDiffValues.java

/**
 * This program takes the file with all possible combinations of variables and creates two set of variables for
 * relating the variable names to positions in the binary diff. Additionally a patch is created containing the
 * expected chunks from a binary diff.//w w w  .  j  a v a 2  s .  co  m
 * 
 * @param args
 */
@SuppressWarnings("static-access")
public static void main(String[] args) {
    String variablesInName = "";
    String outputDir = "";
    String seti = "";
    Options options = new Options();
    try {
        CommandLineParser CLparser = new PosixParser();

        // create the Options
        options.addOption(OptionBuilder.isRequired().withLongOpt("variablesIn")
                .withDescription("[in] file containing the variables").hasArg().withArgName("file")
                .create('i'));
        options.addOption(OptionBuilder.isRequired().withLongOpt("dir")
                .withDescription("[out] output directory").hasArg().withArgName("file").create('d'));
        options.addOption(OptionBuilder.withLongOpt("seti").withDescription("[in] enable seti-chain patching")
                .hasArg().withArgName("file").create('s'));
        options.addOption(OptionBuilder.withLongOpt("version").withDescription("version").create('v'));

        CommandLine line = CLparser.parse(options, args);

        if (line.hasOption("v")) {
            Info.printVersion("GenerateBinaryDiffValues");
            Runtime.getRuntime().exit(0);
        }
        if (line.hasOption("i")) {
            variablesInName = line.getOptionValue("i");
        }
        if (line.hasOption("s")) {
            seti = line.getOptionValue("s");
        }
        if (line.hasOption("d")) {
            outputDir = line.getOptionValue("d");
        }

        exec(variablesInName, outputDir, seti, "TEMPLATE");
    } catch (ParseException e) {
        HelpFormatter formatter = new HelpFormatter();
        formatter.printHelp(Info.getVersionString("GenerateBinaryDiffValues"), options);
    } catch (Exception e) {
        System.out.println("GenerateBinaryDiffValues error: " + e);
        e.printStackTrace();
    }

}

From source file:org.schreibubi.JCombinationsTools.generatePatchTemplate.GeneratePatchTemplate.java

/**
 * @param args/*from  w w w  .j  a v  a  2 s  . com*/
 *            binaryDiffResult allPossibleChunks difftemplate
 */
@SuppressWarnings("static-access")
public static void main(String[] args) {
    String diffResultFile = "";
    String diffTemplateFile = "";
    String possibleChunksFile = "";
    String possibleCombinationsIn = "";
    String possibleCombinationsOut = "";
    String seti = "";
    String templateNameFilter = "";
    Options options = new Options();
    try {
        CommandLineParser CLparser = new PosixParser();

        // create the Options
        options.addOption(OptionBuilder.isRequired().withLongOpt("diffResult")
                .withDescription("[in] file containing the result of the binary diff").hasArg()
                .withArgName("file").create('d'));
        options.addOption(OptionBuilder.isRequired().withLongOpt("possibleChunks")
                .withDescription("[in] file containing the possible chunks").hasArg().withArgName("file")
                .create('p'));
        options.addOption(OptionBuilder.isRequired().withLongOpt("possibleCombinationsIn")
                .withDescription("[in] list of all possible combinations").hasArg().withArgName("file")
                .create('i'));
        options.addOption(OptionBuilder.isRequired().withLongOpt("filter")
                .withDescription("filter only test which have this value in the TEMPLATE variable").hasArg()
                .withArgName("file").create('f'));
        options.addOption(OptionBuilder.isRequired().withLongOpt("possibleCombinationsOut")
                .withDescription("[out] list of all possible combinations").hasArg().withArgName("file")
                .create('o'));
        options.addOption(OptionBuilder.isRequired().withLongOpt("diffTemplate")
                .withDescription("[out] template for generating the patch chunks").hasArg().withArgName("file")
                .create('t'));
        options.addOption(OptionBuilder.withLongOpt("seti").withDescription("[in] enable seti-chain patching")
                .hasArg().withArgName("file").create('s'));
        options.addOption(OptionBuilder.withLongOpt("version").withDescription("version").create('v'));

        CommandLine line = CLparser.parse(options, args);

        if (line.hasOption("v")) {
            Info.printVersion("GeneratepatchTemplate");
            Runtime.getRuntime().exit(0);
        }
        if (line.hasOption("d")) {
            diffResultFile = line.getOptionValue("d");
        }
        if (line.hasOption("t")) {
            diffTemplateFile = line.getOptionValue("t");
        }
        if (line.hasOption("p")) {
            possibleChunksFile = line.getOptionValue("p");
        }
        if (line.hasOption("i")) {
            possibleCombinationsIn = line.getOptionValue("i");
        }
        if (line.hasOption("o")) {
            possibleCombinationsOut = line.getOptionValue("o");
        }
        if (line.hasOption("f")) {
            templateNameFilter = line.getOptionValue("f");
        }
        if (line.hasOption("s")) {
            seti = line.getOptionValue("s");
        }

        exec(diffResultFile, possibleChunksFile, diffTemplateFile, possibleCombinationsIn, templateNameFilter,
                possibleCombinationsOut, seti);

    } catch (ParseException e) {
        HelpFormatter formatter = new HelpFormatter();
        formatter.printHelp(Info.getVersionString("GeneratePatchTemplate"), options);
    } catch (Exception e) {
        System.out.println("GeneratePatchTemplate error: " + e);
        e.printStackTrace();
    }
}

From source file:org.schreibubi.JCombinationsTools.mergeResults.MergeResults.java

/**
 * @param args/*from   w  w  w.ja  v a  2s  .c  o m*/
 */
@SuppressWarnings("static-access")
public static void main(String[] args) {
    Options options = new Options();
    try {

        Properties defaultProperties = new Properties();
        Properties userProperties = new Properties(defaultProperties);

        defaultProperties.setProperty("triggerTrimColumn", "TRIM");
        defaultProperties.setProperty("triggerMeasureColumn", "MEASURE");
        defaultProperties.setProperty("trimColumns",
                "TRIM_TESTMODE,TRIM_TRIMMING,TRIM_RELATIVE,TRIM_ABS,TRIM_PATNAME,FORCE_VALUE");
        defaultProperties.setProperty("trimAbsColumn", "TRIM_ABS");
        defaultProperties.setProperty("trimRelativeColumn", "TRIM_RELATIVE");
        defaultProperties.setProperty("subtitleColumn", "COMMENT");
        defaultProperties.setProperty("dutSelection", "1-1024");
        defaultProperties.setProperty("dutOffset", "32");
        defaultProperties.setProperty("zip", "false");

        try {
            userProperties.loadFromXML(new FileInputStream("config.xml"));
        } catch (FileNotFoundException e) {
        }

        String dclogFile = "";
        ArrayList<String> dclogFiles = new ArrayList<String>();
        String outputFile = "";
        String combinationsFile = "";
        String triggerTrimColumn = userProperties.getProperty("triggerTrimColumn");
        String triggerMeasureColumn = userProperties.getProperty("triggerMeasureColumn");
        String trimColumnsString = userProperties.getProperty("trimColumns");
        String trimAbsColumn = userProperties.getProperty("trimAbsColumn");
        String trimRelativeColumn = userProperties.getProperty("trimRelativeColumn");
        String subtitleColumn = userProperties.getProperty("subtitleColumn");
        String dutSelectionString = userProperties.getProperty("dutSelection");
        String dutOffsetString = userProperties.getProperty("dutOffset");
        boolean zip = Boolean.parseBoolean(userProperties.getProperty("zip"));

        CommandLineParser CLparser = new PosixParser();

        // create the Options
        options.addOption(OptionBuilder.withLongOpt("dclog").withDescription("[in] dclog-files").hasArg()
                .withArgName("file").create('d'));
        options.addOption(OptionBuilder.isRequired().withLongOpt("combinations")
                .withDescription("[in] combinations file").hasArg().withArgName("file").create('c'));
        options.addOption(OptionBuilder.withLongOpt("output").withDescription("[out] output file").hasArg()
                .withArgName("file").create('o'));
        options.addOption(OptionBuilder.withLongOpt("trim")
                .withDescription("Column name of trim column, defaults to " + triggerTrimColumn).hasArg()
                .withArgName("column").create('t'));
        options.addOption(OptionBuilder.withLongOpt("measure")
                .withDescription("Column name of measure column, defaults to " + triggerMeasureColumn).hasArg()
                .withArgName("column").create('m'));
        options.addOption(OptionBuilder.withLongOpt("xvals")
                .withDescription("Column name containing the x-values, defaults to " + trimColumnsString)
                .hasArg().withArgName("column").create('x'));
        options.addOption(OptionBuilder.withLongOpt("relative")
                .withDescription(
                        "Column name containing the relative changes, defaults to " + trimRelativeColumn)
                .hasArg().withArgName("column").create('r'));
        options.addOption(OptionBuilder.withLongOpt("subtitle")
                .withDescription(
                        "Column name containing the subtitles for the shmoos, defaults to " + subtitleColumn)
                .hasArg().withArgName("column").create('s'));
        options.addOption(OptionBuilder.withLongOpt("zip").withDescription("zip output file").create('z'));
        options.addOption(
                OptionBuilder.withLongOpt("dut").withDescription("use only DUTs " + dutSelectionString).hasArg()
                        .withArgName("column").create('u'));
        options.addOption(OptionBuilder.withLongOpt("dutOffset")
                .withDescription("dut offset when merging multiple measurments " + dutOffsetString).hasArg()
                .withArgName("offset").create('f'));
        options.addOption(OptionBuilder.withLongOpt("version").withDescription("version").create('v'));

        CommandLine line = CLparser.parse(options, args);

        if (line.hasOption("v")) {
            Info.printVersion("MergeResults");
            Runtime.getRuntime().exit(0);
        }
        if (line.hasOption("c")) {
            combinationsFile = line.getOptionValue("c");
        }

        if (line.hasOption("d")) {
            dclogFile = line.getOptionValue("d");
            String[] dF = dclogFile.split(",");
            for (String s : dF) {
                dclogFiles.add(s);
            }
        } else {
            int dotPos = combinationsFile.lastIndexOf(".");
            if (dotPos > -1) {
                dclogFiles.add("dclog_af_b_source.csv_" + combinationsFile.substring(0, dotPos));
            } else {
                dclogFiles.add("dclog_af_b_source.csv_" + combinationsFile);
            }
        }

        if (line.hasOption("o")) {
            outputFile = line.getOptionValue("o");
        } else {
            int dotPos = combinationsFile.lastIndexOf(".");
            if (dotPos > -1) {
                outputFile = combinationsFile.substring(0, dotPos) + ".xml";
            } else {
                outputFile = combinationsFile + ".xml";
            }
        }

        if (line.hasOption("t")) {
            triggerTrimColumn = line.getOptionValue("t");
        }
        if (line.hasOption("m")) {
            triggerMeasureColumn = line.getOptionValue("m");
        }
        if (line.hasOption("x")) {
            trimColumnsString = line.getOptionValue("x");
        }
        if (line.hasOption("r")) {
            trimRelativeColumn = line.getOptionValue("r");
        }
        if (line.hasOption("s")) {
            subtitleColumn = line.getOptionValue("s");
        }
        if (line.hasOption("z")) {
            zip = true;
        }
        if (line.hasOption("u")) {
            dutSelectionString = line.getOptionValue("u");
        }
        if (line.hasOption("f")) {
            dutOffsetString = line.getOptionValue("f");
        }

        String[] tC = trimColumnsString.split(",");
        VArrayList<String> trimColumns = new VArrayList<String>();
        for (String s : tC) {
            trimColumns.add(s);
        }

        String[] dS = dutSelectionString.split("-");
        if (dS.length < 2)
            throw new Exception("dut specification is wrong, should be e.g. 1-16");
        int dutStart = Integer.parseInt(dS[0]);
        int dutStop = Integer.parseInt(dS[1]);

        int dutOffset = Integer.parseInt(dutOffsetString);
        merge(dclogFiles, combinationsFile, outputFile, zip, triggerTrimColumn, trimRelativeColumn,
                trimAbsColumn, trimColumns, triggerMeasureColumn, subtitleColumn, dutStart, dutStop, dutOffset);

    } catch (ParseException e) {
        HelpFormatter formatter = new HelpFormatter();
        formatter.printHelp(Info.getVersionString("MergeResults"), options);
    } catch (Exception e) {
        System.out.println("MergeResults error: " + e);
        e.printStackTrace();
    }

}

From source file:org.schreibubi.JCombinationsTools.templateEngine.TemplateEngine.java

/**
 * TemplateEngine/* ww  w .j  a v  a 2s.  c  o m*/
 * 
 * @param args
 *            assignments template
 */
@SuppressWarnings("static-access")
public static void main(String[] args) {
    Options options = new Options();
    try {
        CommandLineParser CLparser = new PosixParser();

        // create the Options
        options.addOption(OptionBuilder.isRequired().withLongOpt("output-filename")
                .withDescription("[out] which variable is used for nameing the files").hasArg()
                .withArgName("variable name").create('o'));
        options.addOption(OptionBuilder.withLongOpt("multifile")
                .withDescription(
                        "output template to multiple files, -o contains variable name to use for filename")
                .create('m'));
        options.addOption(OptionBuilder.withLongOpt("multitemplate")
                .withDescription("use multiple templates, -t contains variable name to use for template")
                .create('u'));
        options.addOption(OptionBuilder.isRequired().withLongOpt("template")
                .withDescription("[in] the file containing the template to process").hasArg()
                .withArgName("file").create('t'));
        options.addOption(OptionBuilder.isRequired().withLongOpt("variables").withDescription(
                "[in] a file containing the values of the variables which should be replaced in the template")
                .hasArg().withArgName("file").create('v'));
        options.addOption(OptionBuilder.withLongOpt("outputDir")
                .withDescription("output directory to write the generated files to.").hasArg()
                .withArgName("file").create('d'));
        options.addOption(OptionBuilder.withLongOpt("header").withDescription("header to insert in each file")
                .hasArg().withArgName("file").create('h'));
        options.addOption(OptionBuilder.withLongOpt("footer").withDescription("footer to insert in each file")
                .hasArg().withArgName("file").create('f'));
        options.addOption(OptionBuilder.withLongOpt("version").withDescription("version").create('v'));

        CommandLine line = CLparser.parse(options, args);

        if (line.hasOption("v")) {
            Info.printVersion("TemplateEngine");
            Runtime.getRuntime().exit(0);
        }
        boolean generateSeparateFilesSwitch = false;
        if (line.hasOption("m")) {
            generateSeparateFilesSwitch = true;
        }
        boolean multiTemplateSwitch = false;
        if (line.hasOption("u")) {
            multiTemplateSwitch = true;
        }
        String outputFilenameOrVariable = "";
        if (line.hasOption("o")) {
            outputFilenameOrVariable = line.getOptionValue("o");
        }
        String templateFilenameOrVariable = "";
        if (line.hasOption("t")) {
            templateFilenameOrVariable = line.getOptionValue("t");
        }
        String variablesFilename = "";
        if (line.hasOption("v")) {
            variablesFilename = line.getOptionValue("v");
        }
        String outputDir = null;
        if (line.hasOption("d")) {
            outputDir = line.getOptionValue("d", null);
        }
        String header = null;
        if (line.hasOption("h")) {
            header = line.getOptionValue("h", null);
        }
        String footer = null;
        if (line.hasOption("f")) {
            outputDir = line.getOptionValue("f", null);
        }

        File variablesFile = new File(variablesFilename);
        File headerFile = new File(header);
        File footerFile = new File(footer);
        File inputDirFile = new File(".");
        File outputDirFile = new File(outputDir);

        exec(variablesFile, generateSeparateFilesSwitch, outputFilenameOrVariable, multiTemplateSwitch,
                templateFilenameOrVariable, inputDirFile, outputDirFile, headerFile, footerFile);
    } catch (ParseException e) {
        HelpFormatter formatter = new HelpFormatter();
        formatter.printHelp(Info.getVersionString("TemplateEngine"), options);
    } catch (Exception e) {
        System.out.println("TemplateEngine error: " + e.getMessage());
        e.printStackTrace();
        System.exit(1);
    }
}

From source file:sos.scheduler.cron.CronConverter.java

/**
 * @param args//w w w  . jav  a  2 s.  co m
 */
public static void main(final String[] args) {

    Logger logger = Logger.getLogger(CronConverter.class);
    @SuppressWarnings("unused")
    Log4JHelper objLogger = null;

    objLogger = new Log4JHelper(null);

    logger = Logger.getRootLogger();
    logger.info("SOS CronConverter - Main"); //$NON-NLS-1$

    /*try {
         test();
       } catch(Exception ex){
    ex.printStackTrace();
       }
    */
    try {
        //SOSArguments arguments = new SOSArguments(args);
        SOSLogger sosLogger;
        String sourceFile = "";
        String targetFile = "";
        String changeUser = "";
        File source = null;
        File target = null;
        int logLevel = 0;
        boolean sysTab = false;
        boolean useOldRunTime = false;
        String jobTimeout = "";
        /*
        try {
           sourceFile = arguments.as_string("-crontab=");
           if (sourceFile.equalsIgnoreCase("/etc/crontab")) sysTab = true;
           targetFile = arguments.as_string("-target=");
           logLevel = arguments.as_int("-v=",SOSStandardLogger.INFO);
           sysTab = arguments.as_bool("-system=",sysTab);
           useOldRunTime = arguments.as_bool("-oldRunTime=",false);
           changeUser = arguments.as_string("-change-user=", "su");
        } catch (Exception e1) {
           System.out.println(e1.getMessage());
           showUsage();
           System.exit(0);
        }*/
        Options options = new Options();
        OptionBuilder.withArgName("0|1");
        OptionBuilder.hasArg();
        OptionBuilder.withDescription("set to 1 if source is the system crontab (with user field)");

        Option optSysTab = OptionBuilder.create(conOptionsSYSTAB);

        OptionBuilder.withArgName("file");
        OptionBuilder.hasArgs();
        OptionBuilder.isRequired();
        OptionBuilder.withDescription("crontab file");

        Option optSourceFile = OptionBuilder.create(conOptionCRONTAB);
        OptionBuilder.withArgName("file");
        OptionBuilder.hasArgs();
        OptionBuilder.isRequired();
        OptionBuilder.withDescription("xml configuration file");

        Option optTargetFile = OptionBuilder.create(conOptionTARGET);
        OptionBuilder.withArgName("level");
        OptionBuilder.hasArg();
        OptionBuilder.withType(new Integer(0));
        OptionBuilder.withDescription("loglevel [0=info] [1=debug1]...[9=debug]");

        Option optLogLevel = OptionBuilder.create(conOptionVERBOSE);

        OptionBuilder.withArgName("command");
        OptionBuilder.hasArgs();
        OptionBuilder.withDescription(
                "change user command for -systab=1. 'su' or 'sudo' or define your own command using $SCHEDULER_CRONTAB_USER.");

        Option optChangeUser = OptionBuilder.create(conOptionCHANGEUSER);

        OptionBuilder.withArgName("seconds");
        OptionBuilder.hasArg();
        OptionBuilder.withDescription("job timeout (0 for unlimited");
        @SuppressWarnings("unused")
        Option optTimeOut = OptionBuilder.create(conOptionTIMEOUT);
        @SuppressWarnings("unused")
        Option optOldRunTime = new Option("oldRunTime", "");

        OptionBuilder.withArgName("true|false");
        OptionBuilder.hasArg();
        OptionBuilder.withDescription("set to true if script has to be mok'ed");
        Option optCreateMok = OptionBuilder.create(conOptionCREATE_MOCK);

        OptionBuilder.withArgName("true|false");
        OptionBuilder.hasArg();
        OptionBuilder.withDescription("set to true if you want to create jobChains and jobs");
        Option optCreateJobChains = OptionBuilder.create(conOptionCREATE_JobChains);

        options.addOption(optSysTab);
        options.addOption(optSourceFile);
        options.addOption(optTargetFile);
        options.addOption(optLogLevel);
        options.addOption(optChangeUser);
        options.addOption(optCreateMok);
        options.addOption(optCreateJobChains);

        CommandLineParser parser = new GnuParser();
        CommandLine line = null;
        try {
            line = parser.parse(options, args);
        } catch (Exception e) {
            HelpFormatter formatter = new HelpFormatter();
            formatter.printHelp("cronconverter", options, true);
            System.exit(0);
        }

        sourceFile = getWholeArgument(line.getOptionValues(conOptionCRONTAB));
        if (sourceFile.equalsIgnoreCase(conSystemCrontabName))
            sysTab = true;
        targetFile = getWholeArgument(line.getOptionValues(conOptionTARGET));

        String ll = line.getOptionValue(conOptionVERBOSE, "" + SOSStandardLogger.INFO);
        logLevel = Integer.parseInt(ll);
        if (line.hasOption(optSysTab.getOpt())) {
            sysTab = line.getOptionValue(optSysTab.getOpt()).trim().equals("1");
        }
        useOldRunTime = line.hasOption("oldRunTime");
        changeUser = "";
        if (line.hasOption(conOptionCHANGEUSER)) {
            changeUser = getWholeArgument(line.getOptionValues(conOptionCHANGEUSER));
        }

        jobTimeout = line.getOptionValue(conOptionTIMEOUT);
        if (logLevel == 0)
            logLevel = SOSLogger.INFO;
        sosLogger = new SOSStandardLogger(logLevel);

        target = new File(targetFile);
        source = new File(sourceFile);

        CronConverter cc = new CronConverter(sosLogger);
        if (jobTimeout != null && jobTimeout.length() > 0) {
            cc.setTimeout(jobTimeout);
        }
        cc.setChangeUserCommand(changeUser);
        if (line.hasOption(conOptionCREATE_MOCK)) { // JITL-28
            cc.setCreateAMock(line.getOptionValue(conOptionCREATE_MOCK).equalsIgnoreCase(conTRUE));
        }
        if (line.hasOption(conOptionCREATE_JobChains)) { // JITL-28
            cc.setCreateJobChainJobs(line.getOptionValue(conOptionCREATE_JobChains).equalsIgnoreCase(conTRUE));
        }

        cc.setSystemCronTab(sysTab);
        cc.oldRunTime = useOldRunTime;
        cc.cronFile2SchedulerXMLFile(source, target);

    } catch (Exception e) {
        e.printStackTrace();
    }

}

From source file:sos.scheduler.cron.CrontabFileConverter.java

/**
 * @param args/*from  ww w  .  ja v a2  s. c o  m*/
 */
public static void main(final String[] args) {

    Logger logger = Logger.getLogger(CrontabFileConverter.class);
    @SuppressWarnings("unused")
    Log4JHelper objLogger = null;

    objLogger = new Log4JHelper(null);

    logger = Logger.getRootLogger();
    logger.info("SOS CronConverter - Main"); //$NON-NLS-1$

    /*try {
         test();
       } catch(Exception ex){
    ex.printStackTrace();
       }
    */
    try {
        //SOSArguments arguments = new SOSArguments(args);
        SOSLogger sosLogger;
        String sourceFile = "";
        String targetFile = "";
        String changeUser = "";
        File source = null;
        File target = null;
        int logLevel = 0;
        boolean sysTab = false;
        boolean useOldRunTime = false;
        String jobTimeout = "";
        /*
        try {
           sourceFile = arguments.as_string("-crontab=");
           if (sourceFile.equalsIgnoreCase("/etc/crontab")) sysTab = true;
           targetFile = arguments.as_string("-target=");
           logLevel = arguments.as_int("-v=",SOSStandardLogger.INFO);
           sysTab = arguments.as_bool("-system=",sysTab);
           useOldRunTime = arguments.as_bool("-oldRunTime=",false);
           changeUser = arguments.as_string("-change-user=", "su");
        } catch (Exception e1) {
           System.out.println(e1.getMessage());
           showUsage();
           System.exit(0);
        }*/
        Options options = new Options();
        OptionBuilder.withArgName("0|1");
        OptionBuilder.hasArg();
        OptionBuilder.withDescription("set to 1 if source is the system crontab (with user field)");

        Option optSysTab = OptionBuilder.create(conOptionsSYSTAB);

        OptionBuilder.withArgName("file");
        OptionBuilder.hasArgs();
        OptionBuilder.isRequired();
        OptionBuilder.withDescription("crontab file");

        Option optSourceFile = OptionBuilder.create(conOptionCRONTAB);
        OptionBuilder.withArgName("file");
        OptionBuilder.hasArgs();
        OptionBuilder.isRequired();
        OptionBuilder.withDescription("xml configuration file");

        Option optTargetFile = OptionBuilder.create(conOptionTARGET);
        OptionBuilder.withArgName("level");
        OptionBuilder.hasArg();
        OptionBuilder.withType(new Integer(0));
        OptionBuilder.withDescription("loglevel [0=info] [1=debug1]...[9=debug]");

        Option optLogLevel = OptionBuilder.create(conOptionVERBOSE);

        OptionBuilder.withArgName("command");
        OptionBuilder.hasArgs();
        OptionBuilder.withDescription(
                "change user command for -systab=1. 'su' or 'sudo' or define your own command using $SCHEDULER_CRONTAB_USER.");

        Option optChangeUser = OptionBuilder.create(conOptionCHANGEUSER);

        OptionBuilder.withArgName("seconds");
        OptionBuilder.hasArg();
        OptionBuilder.withDescription("job timeout (0 for unlimited");
        @SuppressWarnings("unused")
        Option optTimeOut = OptionBuilder.create(conOptionTIMEOUT);
        @SuppressWarnings("unused")
        Option optOldRunTime = new Option("oldRunTime", "");

        OptionBuilder.withArgName("true|false");
        OptionBuilder.hasArg();
        OptionBuilder.withDescription("set to true if script has to be mok'ed");
        Option optCreateMok = OptionBuilder.create(conOptionCREATE_MOCK);

        OptionBuilder.withArgName("true|false");
        OptionBuilder.hasArg();
        OptionBuilder.withDescription("set to true if you want to create jobChains and jobs");
        Option optCreateJobChains = OptionBuilder.create(conOptionCREATE_JobChains);

        options.addOption(optSysTab);
        options.addOption(optSourceFile);
        options.addOption(optTargetFile);
        options.addOption(optLogLevel);
        options.addOption(optChangeUser);
        options.addOption(optCreateMok);
        options.addOption(optCreateJobChains);

        CommandLineParser parser = new GnuParser();
        CommandLine line = null;
        try {
            line = parser.parse(options, args);
        } catch (Exception e) {
            HelpFormatter formatter = new HelpFormatter();
            formatter.printHelp("cronconverter", options, true);
            System.exit(0);
        }

        sourceFile = getWholeArgument(line.getOptionValues(conOptionCRONTAB));
        if (sourceFile.equalsIgnoreCase(conSystemCrontabName))
            sysTab = true;
        targetFile = getWholeArgument(line.getOptionValues(conOptionTARGET));

        String ll = line.getOptionValue(conOptionVERBOSE, "" + SOSStandardLogger.INFO);
        logLevel = Integer.parseInt(ll);
        if (line.hasOption(optSysTab.getOpt())) {
            sysTab = line.getOptionValue(optSysTab.getOpt()).trim().equals("1");
        }
        useOldRunTime = line.hasOption("oldRunTime");
        changeUser = "";
        if (line.hasOption(conOptionCHANGEUSER)) {
            changeUser = getWholeArgument(line.getOptionValues(conOptionCHANGEUSER));
        }

        jobTimeout = line.getOptionValue(conOptionTIMEOUT);
        if (logLevel == 0)
            logLevel = SOSLogger.INFO;
        sosLogger = new SOSStandardLogger(logLevel);

        target = new File(targetFile);
        source = new File(sourceFile);

        CrontabFileConverter cc = new CrontabFileConverter(sosLogger);
        if (jobTimeout != null && jobTimeout.length() > 0) {
            cc.setTimeout(jobTimeout);
        }
        cc.setChangeUserCommand(changeUser);
        if (line.hasOption(conOptionCREATE_MOCK)) { // JITL-28
            cc.setCreateAMock(line.getOptionValue(conOptionCREATE_MOCK).equalsIgnoreCase(conTRUE));
        }
        if (line.hasOption(conOptionCREATE_JobChains)) { // JITL-28
            cc.setCreateJobChainJobs(line.getOptionValue(conOptionCREATE_JobChains).equalsIgnoreCase(conTRUE));
        }

        //         cc.setCreateAMock(line.getOptionValue(conOptionCREATE_MOCK).equalsIgnoreCase(conTRUE));
        //         cc.setCreateJobChainJobs(line.getOptionValue(conOptionCREATE_JobChains).equalsIgnoreCase(conTRUE));

        cc.setSystemCronTab(sysTab);
        cc.oldRunTime = useOldRunTime;
        cc.cronFile2SchedulerXMLFile(source, target);

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

    System.exit(0);
}

From source file:ubc.pavlab.aspiredb.cli.DecipherPhenotypeUploadCLI.java

@Override
protected void buildOptions() {
    OptionBuilder.hasArg();/*from   w  ww .j a v a2  s . c  om*/
    OptionBuilder.withArgName("Directory");
    OptionBuilder.withDescription("Directory containing csv files");
    OptionBuilder.withLongOpt("directory");
    Option d = OptionBuilder.create('d');

    OptionBuilder.hasArg();
    OptionBuilder.withArgName("File name");
    OptionBuilder.withDescription("The file to parse");
    OptionBuilder.withLongOpt("filename");
    Option f = OptionBuilder.create('f');

    OptionBuilder.isRequired();
    OptionBuilder.hasArg();
    OptionBuilder.withArgName("Project name");
    OptionBuilder.withDescription(
            "The project where this data will reside. Project will be created if does not exist,"
                    + "If the project does exist use the existingproject option to add to an existing project");
    Option project = OptionBuilder.create("project");

    addOption("existingproject", false, "You must use this option if you are adding to an existing project");

    addOption(d);
    addOption(f);
    addOption(project);
}

From source file:ubc.pavlab.aspiredb.cli.DecipherVariantUploadCLI.java

@Override
protected void buildOptions() {
    OptionBuilder.isRequired();
    OptionBuilder.hasArg();/*  www .j ava 2 s. c o  m*/
    OptionBuilder.withArgName("Directory");
    OptionBuilder.withDescription("Directory containing csv files");
    OptionBuilder.withLongOpt("directory");
    Option d = OptionBuilder.create('d');

    OptionBuilder.isRequired();
    OptionBuilder.hasArg();
    OptionBuilder.withArgName("File name");
    OptionBuilder.withDescription("The file to parse");
    OptionBuilder.withLongOpt("filename");
    Option f = OptionBuilder.create('f');

    OptionBuilder.isRequired();
    OptionBuilder.hasArg();
    OptionBuilder.withArgName("Project name");
    OptionBuilder.withDescription(
            "The project where this data will reside. Project will be deleted if existingproject option is not specified,"
                    + "Acceptable values = 'DECIPHER");
    // Decipher will reside in a 'Special project' and are all CNVs
    Option project = OptionBuilder.create("project");

    addOption("existingproject", false, "You must use this option if you are adding to an existing project");

    addOption("dryrun", false, "Use this option to validate your data before uploading");

    addOption(d);
    addOption(f);

    addOption(project);

}

From source file:ubc.pavlab.aspiredb.cli.DGVVariantUploadCLI.java

@Override
protected void buildOptions() {
    OptionBuilder.isRequired();
    OptionBuilder.hasArg();//from  w w  w .  j av a  2 s.co  m
    OptionBuilder.withArgName("Directory");
    OptionBuilder.withDescription("Directory containing csv files");
    OptionBuilder.withLongOpt("directory");
    Option d = OptionBuilder.create('d');

    OptionBuilder.isRequired();
    OptionBuilder.hasArg();
    OptionBuilder.withArgName("File name");
    OptionBuilder.withDescription("The file to parse");
    OptionBuilder.withLongOpt("filename");
    Option f = OptionBuilder.create('f');

    OptionBuilder.isRequired();
    OptionBuilder.hasArg();
    OptionBuilder.withArgName("Project name");
    OptionBuilder.withDescription(
            "The project where this data will reside. Project will be deleted if existingproject option is not specified,"
                    + "Acceptable values = 'DGV");
    // DGV will reside in a 'Special project' and are all CNVs
    /*
     * Option variantType = OptionBuilder.isRequired().hasArg().withArgName( "Variant Type" ) .withDescription(
     * "The type of variant in this file, one of: CNV, Indel, SNV, Inversion" ) .create( "variant" );
     */
    Option project = OptionBuilder.create("project");

    addOption("existingproject", false, "You must use this option if you are adding to an existing project");

    addOption("dryrun", false, "Use this option to validate your data before uploading");

    addOption(d);
    addOption(f);

    addOption(project);

}

From source file:ubc.pavlab.aspiredb.cli.ProjectManagerCLI.java

@Override
protected void buildOptions() {

    OptionBuilder.hasArg();/*from ww  w .  j a v  a  2  s .  co  m*/
    OptionBuilder.withArgName("group name");
    OptionBuilder.withDescription("The group to give permissions to");
    Option groupname = OptionBuilder.create("groupname");

    OptionBuilder.isRequired();
    OptionBuilder.hasArg();
    OptionBuilder.withArgName("Project name");
    OptionBuilder.withDescription("The project that will be affected by these operations");
    Option project = OptionBuilder.create("project");

    OptionBuilder.hasArg();
    OptionBuilder.withArgName("Overlap Project name");
    OptionBuilder
            .withDescription("The project that the other project will have its overlaps calculated against");
    Option projectOverlap = OptionBuilder.create("overlapProject");

    addOption("delete", false, "Using this option will delete the project");
    addOption("grant", false, "Using this option will grant the group read permissions on the project");
    addOption("restrict", false, "Using this option will remove the group's read permissions on the project");

    addOption("populateOverlap", false,
            "Using this option will populate the overlap between project and overlapProject");

    addOption(groupname);
    addOption(project);

    addOption(projectOverlap);
}