int main(int argc, char** argv)
{
  bool showColors = false;
  bool isQuiet = false;
  QString seed;
  QStack<QString> reporterFiles;

  int c, index;

  while ((c = getopt(argc, argv, "cr:s:q")) != -1) {
    switch(c) {
      case 'c':
        showColors = true;
        break;
      case 'q':
        isQuiet = true;
        break;
      case 'r':
        reporterFiles.push(QString(optarg));
        break;
      case 's':
        seed = QString(optarg);
        break;
    }
  }

  if (optind == argc) {
    std::cerr << "Run Jasmine's SpecRunner headlessly" << std::endl << std::endl;
    std::cerr << "  specrunner [-c] [-s seed] [-r report file ...] specrunner.html ..." << std::endl;
    return 1;
  }

  QApplication app(argc, argv);
  app.setApplicationName("jasmine-headless-webkit");
  Runner runner;

  runner.setColors(showColors);
  runner.setQuiet(isQuiet);
  runner.setReportFiles(reporterFiles);
  runner.setSeed(seed);

  for (index = optind; index < argc; index++) {
    runner.addFile(QString::fromLocal8Bit(argv[index]));
  }

  runner.go();

  return app.exec();
}