private boolean connectUsingArgs(BeelineParser beelineParser, CommandLine cl) {
    String driver = null, user = null, pass = "", url = null;
    String auth = null;


    if (cl.hasOption("help")) {
      usage();
      getOpts().setHelpAsked(true);
      return true;
    }
    
    if (cl.hasOption("getUrlsFromBeelineSite")) {
      printBeelineSiteUrls();
      getOpts().setBeelineSiteUrlsAsked(true);
      return true;
    }

    Properties hiveVars = cl.getOptionProperties("hivevar");
    for (String key : hiveVars.stringPropertyNames()) {
      getOpts().getHiveVariables().put(key, hiveVars.getProperty(key));
    }

    Properties hiveConfs = cl.getOptionProperties("hiveconf");
    for (String key : hiveConfs.stringPropertyNames()) {
      setHiveConfVar(key, hiveConfs.getProperty(key));
    }

    driver = cl.getOptionValue("d");
    auth = cl.getOptionValue("a");
    user = cl.getOptionValue("n");
    getOpts().setAuthType(auth);
    if (cl.hasOption("w")) {
      pass = obtainPasswordFromFile(cl.getOptionValue("w"));
    } else {
      if (beelineParser.isPasswordOptionSet) {
        pass = cl.getOptionValue("p");
      }
    }
    url = cl.getOptionValue("u");
    if ((url == null) && cl.hasOption("reconnect")){
      // If url was not specified with -u, but -r was present, use that.
      url = getOpts().getLastConnectedUrl();
    }
    getOpts().setInitFiles(cl.getOptionValues("i"));
    getOpts().setScriptFile(cl.getOptionValue("f"));

    if (url != null) {
      String hplSqlMode = Utils.parsePropertyFromUrl(url, Constants.MODE);
      if ("HPLSQL".equalsIgnoreCase(hplSqlMode)) {
        getOpts().setDelimiter("/");
        getOpts().setEntireLineAsCommand(true);
      }
      // Specifying username/password/driver explicitly will override the values from the url;
      // make sure we don't override the values present in the url with empty values.
      if (user == null) {
        user = Utils.parsePropertyFromUrl(url, JdbcConnectionParams.AUTH_USER);
      }
      if (pass == null) {
        pass = Utils.parsePropertyFromUrl(url, JdbcConnectionParams.AUTH_PASSWD);
      }
      if (driver == null) {
        driver = Utils.parsePropertyFromUrl(url, JdbcConnectionParams.PROPERTY_DRIVER);
      }

      String com;
      String comForDebug;
      if(pass != null) {
        com = constructCmd(url, user, pass, driver, false);
        comForDebug = constructCmd(url, user, pass, driver, true);
      } else {
        com = constructCmdUrl(url, user, driver, false);
        comForDebug = constructCmdUrl(url, user, driver, true);
      }
      debug(comForDebug);
      if (!dispatch(com)) {
        exit = true;
        return false;
      }
      return true;
    }
    // load property file
    String propertyFile = cl.getOptionValue("property-file");
    if (propertyFile != null) {
      try {
        this.consoleReader = new ConsoleReader();
      } catch (IOException e) {
        handleException(e);
      }
      if (!dispatch("!properties " + propertyFile)) {
        exit = true;
        return false;
      } else {
        return true;
      }
    }
    return false;
  }
Entry point to creating a {@link ColorBuffer} with color
enabled or disabled depending on the value of {@link BeeLineOpts#getColor}.
beeline/src/java/org/apache/hive/beeline/BeeLine.java