Package org.apache.commons.cli

Examples of org.apache.commons.cli.BasicParser


   */
  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(optSafeMode);
    opts.addOption(optOffline);
    opts.addOption(optAddress);
   
    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 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;
    }
    credentials = new AuthInfo(cl.getOptionValue("username", "root"), ByteBuffer.wrap(cl.getOptionValue("password", "secret").getBytes()), HdfsZooInstance
View Full Code Here

    String user = null;
    String passw = null;
    Instance instance = null;
    ConsoleReader reader = new ConsoleReader();
    try {
      cl = new BasicParser().parse(opts, args);
     
      if (cl.hasOption(zooKeeperInstance.getOpt()) && cl.getOptionValues(zooKeeperInstance.getOpt()).length != 2)
        throw new MissingArgumentException(zooKeeperInstance);
     
      user = cl.getOptionValue(usernameOption.getOpt());
View Full Code Here

      }
    }
  }
 
  public int run(String[] unprocessed_args) throws Exception {
    Parser p = new BasicParser();
   
    CommandLine cl = p.parse(opts, unprocessed_args);
    String[] args = cl.getArgs();
   
    String username = cl.getOptionValue(usernameOpt.getOpt(), "root");
    String password = cl.getOptionValue(passwordOpt.getOpt(), "secret");
   
View Full Code Here

    opts = new Options();
    addOptions(instanceOpt, zooKeepersOpt, usernameOpt, passwordOpt, scanAuthsOpt, tableNameOpt, createtableOpt, deletetableOpt, createEntriesOpt,
        deleteEntriesOpt, readEntriesOpt, debugOpt);
   
    // parse command line
    cl = new BasicParser().parse(opts, args);
    if (cl.getArgs().length != 0)
      throw new ParseException("unrecognized options " + cl.getArgList());
   
    // optionally enable debugging
    if (hasOpt(debugOpt))
View Full Code Here

        }

        @Override
        public int runCmd(String[] args) throws Exception {
            try {
                BasicParser parser = new BasicParser();
                CommandLine cmdLine = parser.parse(getOptions(), args);
                return runCmd(cmdLine);
            } catch (ParseException e) {
                LOG.error("Error parsing command line arguments : ", e);
                printUsage();
                return -1;
View Full Code Here

    }

    private static ServerConfiguration parseArgs(String[] args)
        throws IllegalArgumentException {
        try {
            BasicParser parser = new BasicParser();
            CommandLine cmdLine = parser.parse(bkOpts, args);

            if (cmdLine.hasOption('h')) {
                throw new IllegalArgumentException();
            }
View Full Code Here

     * Parse console args
     */
    private static ServerConfiguration parseArgs(String[] args)
            throws IllegalArgumentException {
        try {
            BasicParser parser = new BasicParser();
            CommandLine cmdLine = parser.parse(opts, args);

            if (cmdLine.hasOption('h')) {
                throw new IllegalArgumentException();
            }

View Full Code Here

  private static Option startAll = new Option("startAll", "Help Message");
  //@formatter:on

  public static void main(String[] args) {

    CommandLineParser parser = new BasicParser();
    Options options = new Options();
    options.addOption(help);
    options.addOption(stopHub);
    options.addOption(startAll);
    options.addOption(stopHub);

    try {

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

      if (line.hasOption("startAll"))
        startAll();

      if (line.hasOption("stopHub"))
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.