Package org.apache.commons.cli

Examples of org.apache.commons.cli.BasicParser


        // 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


    Option dumpKeys = new Option("d", "dump", false, "dump the key/value pairs");
    opts.addOption(dumpKeys);
    Option histogramOption = new Option("h", "histogram", false, "print a histogram of the key-value sizes");
    opts.addOption(histogramOption);
   
    CommandLine commandLine = new BasicParser().parse(opts, args);
   
    boolean dump = commandLine.hasOption(dumpKeys.getOpt());
    boolean doHistogram = commandLine.hasOption(histogramOption.getOpt());
    long countBuckets[] = new long[11];
    long sizeBuckets[] = new long[countBuckets.length];
View Full Code Here

   */
  public static void main(String[] args) throws Exception {

    Options o = getOptions();
    CommandLine cl = null;
    cl = new BasicParser().parse(o, args);

    String logDir = cl.getOptionValue(o.getOption("d").getOpt());
    String fileNameFilter = null;
    if (cl.hasOption(o.getOption("f").getOpt()))
      fileNameFilter = cl.getOptionValue(o.getOption("f").getOpt());
View Full Code Here

    opts.addOption(optOffline);
    opts.addOption(optAddress);
    opts.addOption(optNoTrash);
   
    try {
      commandLine = new BasicParser().parse(opts, args);
      if (commandLine.getArgs().length != 0)
        throw new ParseException("Extraneous arguments");
     
      safemode = commandLine.hasOption(optSafeMode.getOpt());
      offline = commandLine.hasOption(optOffline.getOpt());
View Full Code Here

    options.addOption(maxOpt);
    options.addOption(tabletOpt);
    options.addOption(rowPatternOpt);
    CommandLine cl;
    try {
      cl = new BasicParser().parse(options, args);
    } catch (ParseException ex) {
      usage();
      return;
    }
View Full Code Here

  }

  private CommandLine parseArgs(String[] args) throws ParseException {
    options.addOption(HELP_OPTION, false, "Show usage");
    addOptions();
    CommandLineParser parser = new BasicParser();
    return parser.parse(options, args);
  }
View Full Code Here

   * @throws ParseException
   */
  public static void main(String[] args) throws IOException, ParseException {
    Options options = createOptions();
   
    CommandLineParser parser = new BasicParser();
    CommandLine cmd = parser.parse( options, args);
    JsonToJava jsonToJava = new JsonToJava();
   
    jsonToJava.setUrl(cmd.getOptionValue(OPTION_URL));
    jsonToJava.setPackage(cmd.getOptionValue(OPTION_PACKAGE));
    jsonToJava.setBaseType(cmd.getOptionValue(OPTION_ROOT));
View Full Code Here

    System.out.println(" --agent-port-no <port-no>          Plan Agent Port No");
  }
 
  private boolean parseArguments(String args[])
  {
    CommandLineParser cmdLnParser = new BasicParser();
    CommandLine cmdLn = null;
    Options optArgs = new Options();

    Option cmdLineArg1 =
        new Option("exeID", "PLAN Execution ID (required)");
    cmdLineArg1.setRequired(true);
    cmdLineArg1.setArgs(1);
    cmdLineArg1.setArgName("plan-execution-id");
    Option cmdLineArg2 =
        new Option("nodeID", "Executed Node ID (required)");
    cmdLineArg2.setRequired(true);
    cmdLineArg2.setArgs(1);
    cmdLineArg2.setArgName("executed-node-id");
    Option cmdLineArg3 =
        new Option("portNo", "PLAN Master listener port no (required)");
    cmdLineArg3.setRequired(true);
    cmdLineArg3.setArgs(1);
    cmdLineArg3.setArgName("port-no");
    Option cmdLineArg4 =
        new Option("agentPortNo", "PLAN Agent Port No (required)");
    cmdLineArg4.setRequired(true);
    cmdLineArg4.setArgs(1);
    cmdLineArg4.setArgName("agent-port-no");
   
    optArgs.addOption(cmdLineArg1);
    optArgs.addOption(cmdLineArg2);
    optArgs.addOption(cmdLineArg3);
    optArgs.addOption(cmdLineArg4);
   
    //parse the arguments
    try
    {
      cmdLn = cmdLnParser.parse(optArgs, args);
    }
    catch (ParseException pe)
    {
      logger.error("Can not parse arguments: " + pe.getMessage());
      HelpFormatter formatter = new HelpFormatter();
View Full Code Here

        Options options = new Options();
        options.addOption("v", "verbose", false, "verbose logging");
        options.addOption("h", "help", false, "print this message");

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

        if (command.hasOption("h")) {
            printHelp(options);
            return;
        }
View Full Code Here

        String strOutputDir = null;
        String strDeviceName = null;
        String strDRWS = null;       
        String strBaseDir = null;       
               
        CommandLineParser parser = new BasicParser();
        Options options = createOptions();
       
        CommandLine cmd = null;
       
        // parse command line passed by user           
        try {
            cmd = parser.parse(options, args, true);
        } catch (ParseException e) {
            reportError("commandLineFailed",
                    new String[] {e.getLocalizedMessage()});
            printUsage();
            System.exit(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.