#include <testgui.hxx>
#include <QApplication>
#include <QCommandLineParser>
#include <version.hxx>

int main(int argc, char *argv[]) try {
  QApplication app(argc, argv);
  app.setApplicationDisplayName(app.tr("WebTester"));
  app.setApplicationName(webtester::package_name().c_str());
  app.setApplicationVersion(webtester::version().c_str());
  QCommandLineParser parser;
  parser.addHelpOption();
  parser.addOption(QCommandLineOption
                   (QStringList()<<"u"<<"url",
                    "set initial URL to <url>", "url"));
  parser.process(app);
  QStringList scripts(parser.positionalArguments());
  TestGUI win(0, parser.value("url"),
              scripts.size()>1?scripts[0]:"",
              scripts.size()>1?scripts[1]:scripts.size()?scripts[0]:"");
  win.show();
  return app.exec();
 } catch (std::exception &x) {
  std::cerr<<"**** error: "<<x.what()<<std::endl;
  return 1;
 }
