summaryrefslogblamecommitdiffstats
path: root/src/main.cpp
blob: 134f3a9ca4c320925d4519efc5ddd818cec02513 (plain) (tree)
1
2
3
4
5
6
7
8
9
10


                       

                             
                   



                                 


                                                                                     
                                                                                                       







                                                                                             


                                                                                                   


                                    
                                   


                                                                                               
                                                                                                                                                      



                          
                                                                                                                                  



                                   
#include "gui.h"

#include <QApplication>
#include <QCommandLineOption>
#include <QCommandLineParser>
#include <iostream>

int main(int argc, char **argv)
{
    QApplication app(argc, argv);
    QCommandLineParser parser;
    parser.setApplicationDescription(QObject::tr("CoW-GUI for dnbd3-fuse sessions"));
    parser.addHelpOption();
    QCommandLineOption sessionOption(QStringList() << QLatin1String("sessionid") << QLatin1String("s"),
        QObject::tr("Session ID to use when talking to server"),
        QLatin1String("sessionid"));
    QCommandLineOption urlOption(QStringList() << QLatin1String("url") << QLatin1String("u"),
        QObject::tr("URL base of server to talk to"),
        QLatin1String("url"));
    QCommandLineOption pidOption(QStringList() << QLatin1String("pid") << QLatin1String("p"),
        QObject::tr("PID of dnbd3-fuse, so we can cancel the upload via SIGQUIT on abort"),
        QLatin1String("pid"));
    QCommandLineOption statusOption(QStringList() << QLatin1String("status") << QLatin1String("f"),
        QObject::tr("Path to dnbd3-fuse cow status file"),
        QLatin1String("path"));
    parser.addOption(sessionOption);
    parser.addOption(urlOption);
    parser.addOption(pidOption);
    parser.addOption(statusOption);
    parser.process(app);

    if (!parser.isSet(sessionOption) || !parser.isSet(urlOption) || !parser.isSet(pidOption)) {
        std::cerr << "Missing command line option!" << parser.isSet(sessionOption) << parser.isSet(urlOption) << parser.isSet(pidOption) << std::endl;
        parser.showHelp();
        return 1;
    }

    Gui window(parser.value(urlOption), parser.value(sessionOption), parser.value(pidOption).toInt(), parser.value(statusOption));

    window.show();
    return QGuiApplication::exec();
}