Example usage for org.apache.commons.cli2 CommandLine getValues

List of usage examples for org.apache.commons.cli2 CommandLine getValues

Introduction

In this page you can find the example usage for org.apache.commons.cli2 CommandLine getValues.

Prototype

List getValues(final Option option);

Source Link

Document

Retrieves the Argument values associated with the specified Option

Usage

From source file:imageClassify.Describe.java

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

    DefaultOptionBuilder obuilder = new DefaultOptionBuilder();
    ArgumentBuilder abuilder = new ArgumentBuilder();
    GroupBuilder gbuilder = new GroupBuilder();

    Option pathOpt = obuilder.withLongName("path").withShortName("p").withRequired(true)
            .withArgument(abuilder.withName("path").withMinimum(1).withMaximum(1).create())
            .withDescription("Data path").create();

    Option descriptorOpt = obuilder.withLongName("descriptor").withShortName("d").withRequired(true)
            .withArgument(abuilder.withName("descriptor").withMinimum(1).create())
            .withDescription("data descriptor").create();

    Option descPathOpt = obuilder.withLongName("file").withShortName("f").withRequired(true)
            .withArgument(abuilder.withName("file").withMinimum(1).withMaximum(1).create())
            .withDescription("Path to generated descriptor file").create();

    Option regOpt = obuilder.withLongName("regression").withDescription("Regression Problem").withShortName("r")
            .create();//from  w  ww  .  ja  va  2s.c o m

    Option helpOpt = obuilder.withLongName("help").withDescription("Print out help").withShortName("h")
            .create();

    Group group = gbuilder.withName("Options").withOption(pathOpt).withOption(descPathOpt)
            .withOption(descriptorOpt).withOption(regOpt).withOption(helpOpt).create();

    try {
        Parser parser = new Parser();
        parser.setGroup(group);
        CommandLine cmdLine = parser.parse(args);

        if (cmdLine.hasOption(helpOpt)) {
            CommandLineUtil.printHelp(group);
            return;
        }

        String dataPath = cmdLine.getValue(pathOpt).toString();
        String descPath = cmdLine.getValue(descPathOpt).toString();
        List<String> descriptor = convert(cmdLine.getValues(descriptorOpt));
        boolean regression = cmdLine.hasOption(regOpt);

        log.debug("Data path : {}", dataPath);
        log.debug("Descriptor path : {}", descPath);
        log.debug("Descriptor : {}", descriptor);
        log.debug("Regression : {}", regression);

        runTool(dataPath, descriptor, descPath, regression);
    } catch (OptionException e) {
        log.warn(e.toString());
        CommandLineUtil.printHelp(group);
    }
}

From source file:it.jnrpe.client.JNRPEClient.java

/**
 * /*  ww w.j ava2 s .co m*/
 * @param args
 *            command line arguments
 *             -
 */
public static void main(final String[] args) {

    Parser parser = new Parser();
    parser.setGroup(configureCommandLine());

    CommandLine cli = null;

    try {
        cli = parser.parse(args);

        if (cli.hasOption("--help")) {
            printUsage(null);
        }

        //timeoutAsUnknown = cli.hasOption("--unknown");

        String sHost = (String) cli.getValue("--host");
        final Long port = (Long) cli.getValue("--port", Long.valueOf(DEFAULT_PORT));
        String sCommand = (String) cli.getValue("--command", "_NRPE_CHECK");

        JNRPEClient client = new JNRPEClient(sHost, port.intValue(), !cli.hasOption("--nossl"));
        client.setTimeout(((Long) cli.getValue("--timeout", Long.valueOf(DEFAULT_TIMEOUT))).intValue());

        if (cli.hasOption("--weakCiherSuites")) {
            client.enableWeakCipherSuites();
        }

        @SuppressWarnings("unchecked")
        List<String> argList = cli.getValues("--arglist");
        ReturnValue ret = client.sendCommand(sCommand, argList.toArray(new String[argList.size()]));

        System.out.println(ret.getMessage());
        System.exit(ret.getStatus().intValue());
    } catch (JNRPEClientException exc) {
        Status returnStatus;

        Throwable cause = exc.getCause();
        if (cli.hasOption("--unknown") && cause instanceof SocketTimeoutException) {
            returnStatus = Status.UNKNOWN;
        } else {
            returnStatus = Status.CRITICAL;
        }

        System.out.println(exc.getMessage());
        System.exit(returnStatus.intValue());
    } catch (OptionException oe) {
        printUsage(oe);
    }
}

From source file:com.martinkampjensen.thesis.Main.java

private static int[] parseIntArray(CommandLine cmdLine, Option option) {
    final List<?> list = cmdLine.getValues(option);
    final int values[] = new int[list.size()];

    for (int i = 0; i < values.length; i++) {
        values[i] = parseInt(list.get(i));
    }// w ww .  j av  a 2s  .  co m

    return values;
}

From source file:com.martinkampjensen.thesis.Main.java

private static void connect(CommandLine cmdLine) {
    // TODO: This approach means that a PDB and a TOP file can be specified, but it is maybe not pretty. It works for now.
    final List<?> values = cmdLine.getValues(_oConnect);
    final String fileOrClassName = (String) values.get(0);
    final File topologyFile = (values.size() == 2 ? new File((String) values.get(1)) : null);
    final Model model = Util.instantiateModel(fileOrClassName, topologyFile);

    Application.connect(model);/*from www .  jav a2s .  co m*/
}

From source file:TrainLogistic.java

private static boolean parseArgs(String[] args) {
    DefaultOptionBuilder builder = new DefaultOptionBuilder();

    Option help = builder.withLongName("help").withDescription("print this list").create();

    Option quiet = builder.withLongName("quiet").withDescription("be extra quiet").create();
    Option scores = builder.withLongName("scores").withDescription("output score diagnostics during training")
            .create();//from ww  w  .  jav a2 s  .  c o m

    ArgumentBuilder argumentBuilder = new ArgumentBuilder();
    Option inputFile = builder.withLongName("input").withRequired(true)
            .withArgument(argumentBuilder.withName("input").withMaximum(1).create())
            .withDescription("where to get training data").create();

    Option outputFile = builder.withLongName("output").withRequired(true)
            .withArgument(argumentBuilder.withName("output").withMaximum(1).create())
            .withDescription("where to get training data").create();

    Option predictors = builder.withLongName("predictors").withRequired(true)
            .withArgument(argumentBuilder.withName("p").create())
            .withDescription("a list of predictor variables").create();

    Option types = builder.withLongName("types").withRequired(true)
            .withArgument(argumentBuilder.withName("t").create())
            .withDescription("a list of predictor variable types (numeric, word, or text)").create();

    Option target = builder.withLongName("target").withRequired(true)
            .withArgument(argumentBuilder.withName("target").withMaximum(1).create())
            .withDescription("the name of the target variable").create();

    Option features = builder.withLongName("features")
            .withArgument(argumentBuilder.withName("numFeatures").withDefault("1000").withMaximum(1).create())
            .withDescription("the number of internal hashed features to use").create();

    Option passes = builder.withLongName("passes")
            .withArgument(argumentBuilder.withName("passes").withDefault("2").withMaximum(1).create())
            .withDescription("the number of times to pass over the input data").create();

    Option lambda = builder.withLongName("lambda")
            .withArgument(argumentBuilder.withName("lambda").withDefault("1e-4").withMaximum(1).create())
            .withDescription("the amount of coefficient decay to use").create();

    Option rate = builder.withLongName("rate")
            .withArgument(argumentBuilder.withName("learningRate").withDefault("1e-3").withMaximum(1).create())
            .withDescription("the learning rate").create();

    Option noBias = builder.withLongName("noBias").withDescription("don't include a bias term").create();

    Option targetCategories = builder.withLongName("categories").withRequired(true)
            .withArgument(argumentBuilder.withName("number").withMaximum(1).create())
            .withDescription("the number of target categories to be considered").create();

    Group normalArgs = new GroupBuilder().withOption(help).withOption(quiet).withOption(inputFile)
            .withOption(outputFile).withOption(target).withOption(targetCategories).withOption(predictors)
            .withOption(types).withOption(passes).withOption(lambda).withOption(rate).withOption(noBias)
            .withOption(features).create();

    Parser parser = new Parser();
    parser.setHelpOption(help);
    parser.setHelpTrigger("--help");
    parser.setGroup(normalArgs);
    parser.setHelpFormatter(new HelpFormatter(" ", "", " ", 130));
    CommandLine cmdLine = parser.parseAndHelp(args);

    if (cmdLine == null) {
        System.out.println(args);
        return false;
    }

    TrainLogistic.inputFile = getStringArgument(cmdLine, inputFile);
    TrainLogistic.outputFile = getStringArgument(cmdLine, outputFile);

    List<String> typeList = Lists.newArrayList();
    for (Object x : cmdLine.getValues(types)) {
        typeList.add(x.toString());
    }

    List<String> predictorList = Lists.newArrayList();
    for (Object x : cmdLine.getValues(predictors)) {
        predictorList.add(x.toString());
    }

    lmp = new LogisticModelParameters();
    lmp.setTargetVariable(getStringArgument(cmdLine, target));
    lmp.setMaxTargetCategories(getIntegerArgument(cmdLine, targetCategories));
    lmp.setNumFeatures(getIntegerArgument(cmdLine, features));
    lmp.setUseBias(!getBooleanArgument(cmdLine, noBias));
    lmp.setTypeMap(predictorList, typeList);

    lmp.setLambda(getDoubleArgument(cmdLine, lambda));
    lmp.setLearningRate(getDoubleArgument(cmdLine, rate));

    TrainLogistic.scores = getBooleanArgument(cmdLine, scores);
    TrainLogistic.passes = getIntegerArgument(cmdLine, passes);

    return true;
}

From source file:haflow.component.mahout.logistic.TrainLogistic.java

private static boolean parseArgs(String[] args) {
    DefaultOptionBuilder builder = new DefaultOptionBuilder();

    Option help = builder.withLongName("help").withDescription("print this list").create();

    Option quiet = builder.withLongName("quiet").withDescription("be extra quiet").create();
    Option scores = builder.withLongName("scores").withDescription("output score diagnostics during training")
            .create();/*  w w  w.  ja v  a 2 s .c  om*/

    ArgumentBuilder argumentBuilder = new ArgumentBuilder();
    Option inputFile = builder.withLongName("input").withRequired(true)
            .withArgument(argumentBuilder.withName("input").withMaximum(1).create())
            .withDescription("where to get training data").create();

    Option outputFile = builder.withLongName("output").withRequired(true)
            .withArgument(argumentBuilder.withName("output").withMaximum(1).create())
            .withDescription("where to get training data").create();
    Option inforFile = builder.withLongName("infor").withRequired(true)
            .withArgument(argumentBuilder.withName("infor").withMaximum(1).create())
            .withDescription("where to store information about the training").create();

    Option predictors = builder.withLongName("predictors").withRequired(true)
            .withArgument(argumentBuilder.withName("p").create())
            .withDescription("a list of predictor variables").create();

    Option types = builder.withLongName("types").withRequired(true)
            .withArgument(argumentBuilder.withName("t").create())
            .withDescription("a list of predictor variable types (numeric, word, or text)").create();

    Option target = builder.withLongName("target").withRequired(true)
            .withArgument(argumentBuilder.withName("target").withMaximum(1).create())
            .withDescription("the name of the target variable").create();

    Option features = builder.withLongName("features")
            .withArgument(argumentBuilder.withName("numFeatures").withDefault("1000").withMaximum(1).create())
            .withDescription("the number of internal hashed features to use").create();

    Option passes = builder.withLongName("passes")
            .withArgument(argumentBuilder.withName("passes").withDefault("2").withMaximum(1).create())
            .withDescription("the number of times to pass over the input data").create();

    Option lambda = builder.withLongName("lambda")
            .withArgument(argumentBuilder.withName("lambda").withDefault("1e-4").withMaximum(1).create())
            .withDescription("the amount of coefficient decay to use").create();

    Option rate = builder.withLongName("rate")
            .withArgument(argumentBuilder.withName("learningRate").withDefault("1e-3").withMaximum(1).create())
            .withDescription("the learning rate").create();

    Option noBias = builder.withLongName("noBias").withDescription("don't include a bias term").create();

    Option targetCategories = builder.withLongName("categories").withRequired(true)
            .withArgument(argumentBuilder.withName("number").withMaximum(1).create())
            .withDescription("the number of target categories to be considered").create();

    Group normalArgs = new GroupBuilder().withOption(help).withOption(quiet).withOption(inputFile)
            .withOption(outputFile).withOption(inforFile).withOption(target).withOption(targetCategories)
            .withOption(predictors).withOption(types).withOption(passes).withOption(lambda).withOption(rate)
            .withOption(noBias).withOption(features).create();

    Parser parser = new Parser();
    parser.setHelpOption(help);
    parser.setHelpTrigger("--help");
    parser.setGroup(normalArgs);
    parser.setHelpFormatter(new HelpFormatter(" ", "", " ", 130));
    CommandLine cmdLine = parser.parseAndHelp(args);

    if (cmdLine == null) {
        return false;
    }

    TrainLogistic.inputFile = getStringArgument(cmdLine, inputFile);
    TrainLogistic.outputFile = getStringArgument(cmdLine, outputFile);
    TrainLogistic.inforFile = getStringArgument(cmdLine, inforFile);

    List<String> typeList = Lists.newArrayList();
    for (Object x : cmdLine.getValues(types)) {
        typeList.add(x.toString());
    }

    List<String> predictorList = Lists.newArrayList();
    for (Object x : cmdLine.getValues(predictors)) {
        predictorList.add(x.toString());
    }

    lmp = new LogisticModelParameters();
    lmp.setTargetVariable(getStringArgument(cmdLine, target));
    lmp.setMaxTargetCategories(getIntegerArgument(cmdLine, targetCategories));
    lmp.setNumFeatures(getIntegerArgument(cmdLine, features));
    lmp.setUseBias(!getBooleanArgument(cmdLine, noBias));
    lmp.setTypeMap(predictorList, typeList);

    lmp.setLambda(getDoubleArgument(cmdLine, lambda));
    lmp.setLearningRate(getDoubleArgument(cmdLine, rate));

    TrainLogistic.scores = getBooleanArgument(cmdLine, scores);
    TrainLogistic.passes = getIntegerArgument(cmdLine, passes);
    System.out.print("infor:" + TrainLogistic.inforFile);

    System.out.println("target:" + getStringArgument(cmdLine, target));
    System.out.println("targetCategories:" + String.valueOf(getStringArgument(cmdLine, targetCategories)));
    System.out.println("features:" + String.valueOf(getStringArgument(cmdLine, features)));
    System.out.println("lambda:" + String.valueOf(getStringArgument(cmdLine, lambda)));
    System.out.println("rate:" + String.valueOf(getStringArgument(cmdLine, rate)));
    return true;
}

From source file:my.mahout.AbstractJob.java

protected static void maybePut(Map<String, List<String>> args, CommandLine cmdLine, Option... opt) {
    for (Option o : opt) {

        // the option appeared on the command-line, or it has a value
        // (which is likely a default value). 
        if (cmdLine.hasOption(o) || cmdLine.getValue(o) != null
                || (cmdLine.getValues(o) != null && !cmdLine.getValues(o).isEmpty())) {

            // nulls are ok, for cases where options are simple flags.
            List<?> vo = cmdLine.getValues(o);
            if (vo != null && !vo.isEmpty()) {
                List<String> vals = Lists.newArrayList();
                for (Object o1 : vo) {
                    vals.add(o1.toString());
                }/*from w w  w .j ava 2s  .  c  o  m*/
                args.put(o.getPreferredName(), vals);
            } else {
                args.put(o.getPreferredName(), null);
            }
        }
    }
}

From source file:com.ibm.jaql.util.shell.JaqlShellArguments.java

@SuppressWarnings("unchecked")
static JaqlShellArguments parseArgs(String... args) {
    // option builders
    final DefaultOptionBuilder obuilder = new DefaultOptionBuilder();
    final ArgumentBuilder abuilder = new ArgumentBuilder();
    final GroupBuilder gbuilder = new GroupBuilder();

    // create standard options
    Option optHelp = obuilder.withShortName("h").withShortName("?").withLongName("help")
            .withDescription("print this message").create();

    Option optJars = obuilder.withShortName("j").withLongName("jars")
            .withDescription(/*from   w w  w .  ja  v a2 s. c o m*/
                    "comma-separated list of jar files to include user defined expressions or data stores")
            .withArgument(abuilder.withName("args").withMinimum(1).withMaximum(1).create()).create();

    Option optSearchPath = obuilder.withShortName("jp").withLongName("jaql-path")
            .withDescription("colon seperated list of all search path entries")
            .withArgument(abuilder.withName("args").withMinimum(1).withMaximum(1).create()).create();

    Option optBatch = obuilder.withShortName("b").withLongName("batch")
            .withDescription("run in batch mode (i.e., do not read from stdin)").create();

    Option optOutOptions = obuilder.withShortName("o").withLongName("outoptions")
            .withDescription("output options: json, del and xml or an output IO descriptor. "
                    + "This option is ignored when not running in batch mode.")
            .withArgument(abuilder.withName("outoptions").withMinimum(1).withMaximum(1).create()).create();

    Option optEval = obuilder.withShortName("e").withLongName("eval")
            .withDescription("evaluate Jaql expression")
            .withArgument(abuilder.withName("expr").withMinimum(1).withMaximum(1).create()).create();

    // create mini-cluster options
    Option optCluster = obuilder.withShortName("c").withLongName("cluster")
            .withDescription("use existing cluster (i.e., do not launch a mini-cluster)").create();

    Option optNumNodes = obuilder.withShortName("n").withLongName("no-nodes")
            .withDescription("mini-cluster option: number of nodes to spawn")
            .withArgument(abuilder.withName("arg").withMinimum(1).withMaximum(1)
                    .withValidator(NumberValidator.getIntegerInstance()).create())
            .create();

    Option optDir = obuilder.withShortName("d").withLongName("hdfs-dir")
            .withDescription("mini-cluster option: root HDFs directory")
            .withArgument(abuilder.withName("arg").withMinimum(1).withMaximum(1).create()).create();

    Group clusterOptions = gbuilder.withName("Cluster options").withOption(optCluster).withOption(optDir)
            .withOption(optNumNodes).create();

    // create input files option
    Option optInputFiles = abuilder.withName("file").withDescription("list of input files").withMinimum(0)
            .create();

    Option optLog = obuilder.withShortName("l").withLongName("log")
            .withDescription("log options: json, del and xml or an output IO descriptor. ")
            .withArgument(abuilder.withName("arg").withMinimum(1).withMaximum(1).create()).create();

    // combine all options
    Group options = gbuilder.withName("options").withOption(optHelp).withOption(optJars)
            .withOption(optSearchPath).withOption(optBatch).withOption(optLog).withOption(optOutOptions)
            .withOption(optEval).withOption(optInputFiles).withOption(clusterOptions).create();

    // parse and print help if necessary
    CommandLine cl;
    try {
        Parser parser = new Parser();
        parser.setGroup(options);
        cl = parser.parse(args);
    } catch (OptionException e) {
        printHelpAndExit(e, null, options);
        return null;
    }
    if (cl.hasOption(optHelp)) {
        printHelpAndExit(null, options);
    }

    // validate arguments
    JaqlShellArguments result = new JaqlShellArguments();

    // mini-cluster options         
    if (cl.hasOption(optCluster)) {
        result.useExistingCluster = true;
    }
    if (cl.hasOption(optDir)) {
        if (result.useExistingCluster) {
            printHelpAndExit("Options " + optCluster.getPreferredName() + " and " + optDir.getPreferredName()
                    + " are mutually exclusive", options);
        }
        result.hdfsDir = (String) cl.getValue(optDir);
    }
    if (cl.hasOption(optNumNodes)) {
        if (result.useExistingCluster) {
            printHelpAndExit("Options " + optCluster.getPreferredName() + " and "
                    + optNumNodes.getPreferredName() + " are mutually exclusive", options);
        }
        result.numNodes = ((Number) cl.getValue(optNumNodes)).intValue();
    }

    // jar files
    if (cl.hasOption(optJars)) {
        result.jars = ((String) cl.getValue(optJars)).split(",");
        for (String jar : result.jars) {
            if (!new File(jar).exists()) {
                printHelpAndExit("Jar file " + jar + " not found", options);
            }
        }
    }

    // search path directories
    if (cl.hasOption(optSearchPath)) {
        result.searchPath = ((String) cl.getValue(optSearchPath)).split(":");
        for (String dir : result.searchPath) {
            if (!new File(dir).exists() || !new File(dir).isDirectory()) {
                printHelpAndExit("Search-path entry " + dir + " not found or is no directory", options);
            }
        }
    }

    if (cl.hasOption(optBatch)) {
        result.batchMode = true;
        if (cl.hasOption(optOutOptions)) {
            String format = (String) cl.getValue(optOutOptions);
            try {
                result.outputAdapter = getOutputAdapter(format);
            } catch (Exception e) {
                printHelpAndExit(e,
                        "\"" + format + "\" is neither a valid output format nor a valid IO descriptor",
                        options);
            }
        }
    }

    // input
    if (cl.hasOption(optEval)) {
        String eval = (String) cl.getValue(optEval);
        if (!eval.endsWith(";"))
            eval += ";";
        result.addInputStream(new ByteArrayInputStream(eval.getBytes()));
    }
    if (cl.hasOption(optInputFiles)) {
        List<String> files = (List<String>) cl.getValues(optInputFiles);
        for (String file : files) {
            try {
                result.addInputStream(new FileInputStream(file));
            } catch (FileNotFoundException e) {
                printHelpAndExit(e, "Input file " + file + " not found", options);
            }
        }
    }

    // error log
    if (cl.hasOption(optLog)) {
        String path = (String) cl.getValue(optLog);
        try {
            BufferedJsonRecord logFD = new BufferedJsonRecord();
            logFD.add(Adapter.TYPE_NAME, new JsonString("local"));
            logFD.add(Adapter.LOCATION_NAME, new JsonString(path));
            OutputAdapter oa = (OutputAdapter) JaqlUtil.getAdapterStore().output.getAdapter(logFD);
            result.logAdapter = oa;
        } catch (Exception e) {
            printHelpAndExit(e, "\"" + path + "\" invalid", options);
        }
    }

    if (!result.batchMode) {
        result.addStdin();
    }

    return result;
}

From source file:org.apache.mahout.classifier.df.tools.ForestVisualizer.java

public static void main(String[] args) {
    DefaultOptionBuilder obuilder = new DefaultOptionBuilder();
    ArgumentBuilder abuilder = new ArgumentBuilder();
    GroupBuilder gbuilder = new GroupBuilder();

    Option datasetOpt = obuilder.withLongName("dataset").withShortName("ds").withRequired(true)
            .withArgument(abuilder.withName("dataset").withMinimum(1).withMaximum(1).create())
            .withDescription("Dataset path").create();

    Option modelOpt = obuilder.withLongName("model").withShortName("m").withRequired(true)
            .withArgument(abuilder.withName("path").withMinimum(1).withMaximum(1).create())
            .withDescription("Path to the Decision Forest").create();

    Option attrNamesOpt = obuilder.withLongName("names").withShortName("n").withRequired(false)
            .withArgument(abuilder.withName("names").withMinimum(1).create())
            .withDescription("Optional, Attribute names").create();

    Option helpOpt = obuilder.withLongName("help").withShortName("h").withDescription("Print out help")
            .create();//from  ww w.  j  a  v a 2 s. c  om

    Group group = gbuilder.withName("Options").withOption(datasetOpt).withOption(modelOpt)
            .withOption(attrNamesOpt).withOption(helpOpt).create();

    try {
        Parser parser = new Parser();
        parser.setGroup(group);
        CommandLine cmdLine = parser.parse(args);

        if (cmdLine.hasOption("help")) {
            CommandLineUtil.printHelp(group);
            return;
        }

        String datasetName = cmdLine.getValue(datasetOpt).toString();
        String modelName = cmdLine.getValue(modelOpt).toString();
        String[] attrNames = null;
        if (cmdLine.hasOption(attrNamesOpt)) {
            Collection<String> names = (Collection<String>) cmdLine.getValues(attrNamesOpt);
            if (!names.isEmpty()) {
                attrNames = new String[names.size()];
                names.toArray(attrNames);
            }
        }

        print(modelName, datasetName, attrNames);
    } catch (Exception e) {
        log.error("Exception", e);
        CommandLineUtil.printHelp(group);
    }
}

From source file:org.apache.mahout.classifier.mlp.RunMultilayerPerceptron.java

/**
 * Parse the arguments./*ww  w. ja v a2s .  c  om*/
 *
 * @param args The input arguments.
 * @param parameters  The parameters need to be filled.
 * @return true or false
 * @throws Exception
 */
private static boolean parseArgs(String[] args, Parameters parameters) throws Exception {
    // build the options
    log.info("Validate and parse arguments...");
    DefaultOptionBuilder optionBuilder = new DefaultOptionBuilder();
    GroupBuilder groupBuilder = new GroupBuilder();
    ArgumentBuilder argumentBuilder = new ArgumentBuilder();

    Option inputFileFormatOption = optionBuilder
            .withLongName("format").withShortName("f").withArgument(argumentBuilder.withName("file type")
                    .withDefault("csv").withMinimum(1).withMaximum(1).create())
            .withDescription("type of input file, currently support 'csv'").create();

    List<Integer> columnRangeDefault = Lists.newArrayList();
    columnRangeDefault.add(0);
    columnRangeDefault.add(Integer.MAX_VALUE);

    Option skipHeaderOption = optionBuilder.withLongName("skipHeader").withShortName("sh").withRequired(false)
            .withDescription("whether to skip the first row of the input file").create();

    Option inputColumnRangeOption = optionBuilder.withLongName("columnRange").withShortName("cr")
            .withDescription("the column range of the input file, start from 0").withArgument(argumentBuilder
                    .withName("range").withMinimum(2).withMaximum(2).withDefaults(columnRangeDefault).create())
            .create();

    Group inputFileTypeGroup = groupBuilder.withOption(skipHeaderOption).withOption(inputColumnRangeOption)
            .withOption(inputFileFormatOption).create();

    Option inputOption = optionBuilder.withLongName("input").withShortName("i").withRequired(true)
            .withArgument(argumentBuilder.withName("file path").withMinimum(1).withMaximum(1).create())
            .withDescription("the file path of unlabelled dataset").withChildren(inputFileTypeGroup).create();

    Option modelOption = optionBuilder.withLongName("model").withShortName("mo").withRequired(true)
            .withArgument(argumentBuilder.withName("model file").withMinimum(1).withMaximum(1).create())
            .withDescription("the file path of the model").create();

    Option labelsOption = optionBuilder.withLongName("labels").withShortName("labels")
            .withArgument(argumentBuilder.withName("label-name").withMinimum(2).create())
            .withDescription("an ordered list of label names").create();

    Group labelsGroup = groupBuilder.withOption(labelsOption).create();

    Option outputOption = optionBuilder.withLongName("output").withShortName("o").withRequired(true)
            .withArgument(
                    argumentBuilder.withConsumeRemaining("file path").withMinimum(1).withMaximum(1).create())
            .withDescription("the file path of labelled results").withChildren(labelsGroup).create();

    // parse the input
    Parser parser = new Parser();
    Group normalOption = groupBuilder.withOption(inputOption).withOption(modelOption).withOption(outputOption)
            .create();
    parser.setGroup(normalOption);
    CommandLine commandLine = parser.parseAndHelp(args);
    if (commandLine == null) {
        return false;
    }

    // obtain the arguments
    parameters.inputFilePathStr = TrainMultilayerPerceptron.getString(commandLine, inputOption);
    parameters.inputFileFormat = TrainMultilayerPerceptron.getString(commandLine, inputFileFormatOption);
    parameters.skipHeader = commandLine.hasOption(skipHeaderOption);
    parameters.modelFilePathStr = TrainMultilayerPerceptron.getString(commandLine, modelOption);
    parameters.outputFilePathStr = TrainMultilayerPerceptron.getString(commandLine, outputOption);

    List<?> columnRange = commandLine.getValues(inputColumnRangeOption);
    parameters.columnStart = Integer.parseInt(columnRange.get(0).toString());
    parameters.columnEnd = Integer.parseInt(columnRange.get(1).toString());

    return true;
}