Package org.apache.commons.cli

Examples of org.apache.commons.cli.Parser


        .create('D'));

    // [-h|--help]
    options.addOption(new Option("h", "help", false, "Print help information"));

    Parser parser = new GnuParser();
    CommandLine cmdLine = null;

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

    } catch (ParseException e) {
      printUsage(options, ss.err);
      System.exit(1);
    }
View Full Code Here


      options.addOption(option);

    }

    Parser createParser() {
      Parser result = new BasicParser();
      return result;
    }
View Full Code Here

        "The output file.  If not specified, dumps to the console", "path");
    cli.addOption("substring", false,
        "The number of chars of the FormatString() to print", "number");
    cli.addOption("count", false, "Report the count only", "number");

    Parser parser = cli.createParser();
    try {
      HamaConfiguration conf = new HamaConfiguration();
      CommandLine cmdLine = parser.parse(cli.options, args);

      if (cmdLine.hasOption("file")) {
        Path path = new Path(cmdLine.getOptionValue("file"));

        FileSystem fs = FileSystem.get(path.toUri(), conf);
View Full Code Here

        false,
        "\"n1=v1,n2=v2,..\" (Deprecated) Optional. Add or override a JobConf property.",
        "key=val");

    cli.addOption("program", false, "URI to application executable", "class");
    Parser parser = cli.createParser();
    try {

      // check generic arguments -conf
      GenericOptionsParser genericParser = new GenericOptionsParser(getConf(),
          args);
      // get other arguments
      CommandLine results = parser.parse(cli.options,
          genericParser.getRemainingArgs());

      BSPJob job = new BSPJob(getConf());

      if (results.hasOption("input")) {
View Full Code Here

     *        the arguments
     */
    private void run(String[] args) {
        try {
            // parse arguments
            Parser parser = new BasicParser();
            org.apache.commons.cli.CommandLine cl = parser.parse(options, args);

            // Set locale
            this.setLocale(cl);

            // Welcome message
View Full Code Here

        .create('p'));

    // [-h|--help]
    options.addOption(new Option("h", "help", false, "Print help information"));

    Parser parser = new GnuParser();
    CommandLine cmdLine = null;

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

    } catch (ParseException e) {
      printUsage(options, ss.err);
      System.exit(1);
    }
View Full Code Here

            java.text.ParseException {
        if (argv.length == 0) {
            printHelp(System.out);
            System.exit(1);
        }
        Parser p = new PosixParser();
        CommandLine cl = p.parse(options, argv);

        /* help option */
        opt = OPT_HELP;
        char c = opt.charAt(0);
        if (cl.hasOption(c)) {
View Full Code Here

        final Option ignoreNotFoundOpt = new Option("i", "ignoreNotFound", false, "If not finding the specified Spring bean should result in an exception.");
        options.addOption(ignoreNotFoundOpt);
       
        final CommandLine commandLine;
        try {
            final Parser cliParser = new PosixParser();
            commandLine = cliParser.parse(options, args);
        }
        catch (ParseException exp) {
            printHelp(options);
            return;
        }
View Full Code Here

    public static void main(String[] args) throws Exception {
        final Options options = DbLoaderConfiguration.getOptions();
       
        final CommandLine commandLine;
        try {
            final Parser cliParser = new PosixParser();
            commandLine = cliParser.parse(options, args);
        }
        catch (ParseException exp) {
            printHelp(options);
            return;
        }
View Full Code Here

    Options opts = new Options();
   
    opts.addOption(usernameOpt);
    opts.addOption(passwordOpt);
   
    Parser p = new BasicParser();
    CommandLine cl = null;
    try {
      cl = p.parse(opts, args);
    } catch (ParseException e1) {
      System.out.println("Parse Exception, exiting.");
      return;
    }
   
View Full Code Here

TOP

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

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.