/**
   * Drives the application.
   *
   * @param args first element would be the svn access configuration file
   * @throws Exception if it fails to generate a report
   */
  public void drive(String[] args) throws Exception {

    // We need an access config file in order to generate a report.
    if (args == null || args.length < 1) {
      System.out.println("=== SVN Access Auditor v1.0 ===");
      System.out.println("Outputs mapping information (HTML) between SVN repos and users. ");
      System.out.println("Usage:");
      System.out.println("  java -jar svnaccessauditor.jar <svnaccess.conf>");
      System.out.println();
      System.out.println("Output: repos.html");
      return;
    }

    File accessConfigFile = new File(args[0]);
    if (!accessConfigFile.exists() || accessConfigFile.isDirectory()) {
      System.out.println("File not exists at: " + args[0]);
      return;
    }

    System.out.println("Processing the records...");
    BufferedReader reader = new BufferedReader(new FileReader(accessConfigFile));
    String line;

    // Let the states handle the records.
    currentState = new InitialState(this);
    while ((line = reader.readLine()) != null) {
      currentState.process(line);
    }
    reader.close();

    // Add all users to EVERYONE group.
    for (User u : users.values()) {
      EVERYONE.addUser(u);
    }
    groups.put("EVERYONE", EVERYONE);

    reportGenerator = new HtmlReportGenerator(users, groups, repos);
    reportGenerator.generateReport();
  }