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

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