Package org.apache.commons.cli

Examples of org.apache.commons.cli.BasicParser


        String strDeviceName = null;
        String strBase = null;
       
        CommandLine cmd = null;       
        try {           
            CommandLineParser parser = new BasicParser();
            Options options = createOptions();
           
            // parse command line passed by user
            cmd = parser.parse(options, args, true);                                   
        } catch (ParseException e) {
            reportError("commandLineFailed",
                    new String[] {e.getLocalizedMessage()});
            printUsage();
            System.exit(1);
View Full Code Here


  }
 
  @Override
  protected boolean parseArgument2(String[] args)
  {
    CommandLineParser cmdLnParser = new BasicParser();
    CommandLine cmdLn = null;
    Options optArgs = new Options();

    Option cmdLineArg1 =
        new Option("exeFile", "Target Execution File (required)");
    cmdLineArg1.setRequired(true);
    cmdLineArg1.setArgs(1);
    cmdLineArg1.setArgName("execution-file");
   
    optArgs.addOption(cmdLineArg1);

    //parse the arguments
    try
    {
      cmdLn = cmdLnParser.parse(optArgs, args);
    }
    catch (ParseException pe)
    {
      logger.error("Can not parse argument: " + pe.getLocalizedMessage());
      HelpFormatter formatter = new HelpFormatter();
View Full Code Here

  }
 
  @Override
  protected boolean parseArgument2(String[] args)
  {
    CommandLineParser cmdLnParser = new BasicParser();
    CommandLine cmdLn = null;
    Options optArgs = new Options();

    Option cmdLineArg1 =
        new Option("dataPointName", "Data Point Name (required)");
    cmdLineArg1.setRequired(true);
    cmdLineArg1.setArgs(1);
    cmdLineArg1.setArgName("data-point-name");
    Option cmdLineArg5 =
        new Option("dataPointValue", "Data Point Value (required)");
    cmdLineArg5.setRequired(true);
    cmdLineArg5.setArgs(1);
    cmdLineArg5.setArgName("data-point-value");
   
    optArgs.addOption(cmdLineArg1);
    optArgs.addOption(cmdLineArg5);

    //parse the arguments
    try
    {
      cmdLn = cmdLnParser.parse(optArgs, args);
    }
    catch (ParseException pe)
    {
      logger.error("Can not parse argument: " + pe.getLocalizedMessage());
      HelpFormatter formatter = new HelpFormatter();
View Full Code Here

     * @param args the arguments provided by the user on the command line.
     */
    public void load(String[] args) {

        Options options = createOptions();
        CommandLineParser parser = new BasicParser();
        try {
            boolean optionValuesValid = true;
            CommandLine cmd = parser.parse(options, args);

            // Check verbose first since that affects everything else.
            Level level = Level.INFO;
            if (cmd.hasOption(VERBOSE)) {
                level = Level.DEBUG;
View Full Code Here

    options.addOption("s", true, "set feature selection metric");
    options.addOption("f", true, "set absolute path to data file");
    options.addOption("d", true, "set data size");

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

      String selector = cmd.getOptionValue("s");
      String file = cmd.getOptionValue("f");

      Filter filter;
View Full Code Here

    String vertexClassName = args[0];
    if(LOG.isDebugEnabled()) {
      LOG.debug("Attempting to run Vertex: " + vertexClassName);
    }

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

    // Verify all the options have been provided
    for (String[] requiredOption : requiredOptions) {
      if(!cmd.hasOption(requiredOption[0])) {
        System.out.println(requiredOption[1]);
View Full Code Here

     <P>Get the CommandLine after parsing the actually-provided command line.</P>

     @return  <CODE><A HREF="~JD~getCommandLine(s[],cliclp)~EJD~">getCommandLine</A>(as_cmdLineParams, (new <A HREF="~JD~clibp#clibp()~EJD~">BasicParser</A>()))</CODE>
   **/
  public final CommandLine getCommandLine(String[] as_cmdLineParams)  {
    return getCommandLine(as_cmdLineParams, (new BasicParser()));
  }
View Full Code Here

        try {
          Options o = new Options();
          o.addOption(OptUtil.tableOpt());
          args[0] = "-t";
          args[1] = tableName;
          CommandLine cl = new BasicParser().parse(o, args);
          pluginClazz = shellState.getClassLoader(cl, shellState).loadClass(ent.getValue()).asSubclass(clazz);
        } catch (ClassNotFoundException e) {
          Logger.getLogger(ShellPluginConfigurationCommand.class).error("Class not found" + e.getMessage());
          return null;
        } catch (ParseException e) {
View Full Code Here

        // Get the options from the command on how to parse the string
        Options parseOpts = sc.getOptionsWithHelp();

        // Parse the string using the given options
        CommandLine cl = new BasicParser().parse(parseOpts, fields);

        int actualArgLen = cl.getArgs().length;
        int expectedArgLen = sc.numArgs();
        if (cl.hasOption(helpOption)) {
          // Display help if asked to; otherwise execute the command
View Full Code Here

        try {
            opts.addOption(buildConfigOption());
            opts.addOption(buildPortOption());
            opts.addOption(buildHelpOption());

            CommandLine cl = new BasicParser().parse(opts, args);

            if (cl.hasOption('h')) {
                printHelpAndExit(opts);
            }
            if (cl.getArgs().length == 1) {
View Full Code Here

TOP

Related Classes of org.apache.commons.cli.BasicParser

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.