public int run(String metastoreHome, String[] args, OptionGroup additionalOptions,
                 Configuration conf) {
    try {
      init(metastoreHome, args, additionalOptions, conf);
      SchemaToolTask task;
      if (cmdLine.hasOption("info")) {
        task = new SchemaToolTaskInfo();
      } else if (cmdLine.hasOption("upgradeSchema") || cmdLine.hasOption("upgradeSchemaFrom")) {
        task = new SchemaToolTaskUpgrade();
      } else if (cmdLine.hasOption("initSchema") || cmdLine.hasOption("initSchemaTo")) {
        task = new SchemaToolTaskInit();
      } else if (cmdLine.hasOption("initOrUpgradeSchema")) {
        task = new SchemaToolTaskInitOrUpgrade();
      } else if (cmdLine.hasOption("validate")) {
        task = new SchemaToolTaskValidate();
      } else if (cmdLine.hasOption("createCatalog")) {
        task = new SchemaToolTaskCreateCatalog();
      } else if (cmdLine.hasOption("alterCatalog")) {
        task = new SchemaToolTaskAlterCatalog();
      } else if (cmdLine.hasOption("mergeCatalog")) {
        task = new SchemaToolTaskMergeCatalog();
      } else if (cmdLine.hasOption("moveDatabase")) {
        task = new SchemaToolTaskMoveDatabase();
      } else if (cmdLine.hasOption("moveTable")) {
        task = new SchemaToolTaskMoveTable();
      } else if (cmdLine.hasOption("createUser")) {
        task = new SchemaToolTaskCreateUser();
      } else if (cmdLine.hasOption("dropAllDatabases")) {
        task = new SchemaToolTaskDrop();
      } else if (cmdLine.hasOption("createLogsTable")) {
        task = new SchemaToolTaskCreateLogsTable();
      } else {
        throw new HiveMetaException("No task defined!");
      }

      task.setHiveSchemaTool(this);
      task.setCommandLineArguments(cmdLine);
      task.execute();
      return 0;
    } catch (HiveMetaException e) {
      logAndPrintToError(e.getMessage());
      if (e.getCause() != null) {
        Throwable t = e.getCause();
        logAndPrintToError("Underlying cause: "
            + t.getClass().getName() + " : "
            + t.getMessage());
        if (e.getCause() instanceof SQLException) {
          logAndPrintToError("SQL Error code: " + ((SQLException) t).getErrorCode());
        }
      }
      if (cmdLine != null) {
        if (cmdLine.hasOption("verbose")) {
          e.printStackTrace();
        } else {
          logAndPrintToError("Use --verbose for detailed stacktrace.");
        }
      }
      logAndPrintToError("*** schemaTool failed ***");
      return 1;

    }
  }
Execute a given metastore script. This default version uses sqlline to execute the files,
which requires only running one file.  Subclasses can use other executors.
@param scriptDir directory script is in
@param scriptFile file in the directory to run
@throws IOException if it cannot read the file or directory
@throws HiveMetaException default implementation never throws this
standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/tools/schematool/MetastoreSchemaTool.java