/**
 * @file main.cpp
 * @brief Entry point for the Qt StreamHub oscilloscope client.
 *
 * Usage: StreamHubQtClient [-host HOST] [-port PORT]
 * Defaults: host 127.0.0.1, port 8090.
 */

#include "MainWindow.h"
#include "Theme.h"

#include <QApplication>
#include <QCommandLineParser>

int main(int argc, char** argv) {
    QApplication app(argc, argv);
    app.setApplicationName("StreamHubQtClient");

    QCommandLineParser parser;
    parser.setApplicationDescription("StreamHub oscilloscope client (Qt)");
    parser.addHelpOption();
    QCommandLineOption hostOpt({"H", "host"}, "Hub host", "host", "127.0.0.1");
    QCommandLineOption portOpt({"p", "port"}, "Hub WS port", "port", "8090");
    parser.addOption(hostOpt);
    parser.addOption(portOpt);
    parser.process(app);

    const QString host = parser.value(hostOpt);
    const uint16_t port = static_cast<uint16_t>(parser.value(portOpt).toUInt());

    shq::applyTheme(app);

    shq::MainWindow win(host, port ? port : 8090);
    win.show();
    return app.exec();
}
