summaryrefslogtreecommitdiffstats
path: root/src/main.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/main.cpp')
-rw-r--r--src/main.cpp26
1 files changed, 25 insertions, 1 deletions
diff --git a/src/main.cpp b/src/main.cpp
index 310d2a3..51c9899 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -1,11 +1,35 @@
#include "gui.h"
#include <QApplication>
+#include <QCommandLineOption>
+#include <QCommandLineParser>
int main(int argc, char **argv)
{
QApplication app(argc, argv);
- Gui window("http://10.4.9.57/cow/", "uuuuuuid");
+ QCommandLineParser parser;
+ parser.setApplicationDescription(QObject::tr("CoW-GUI for dnbd3-fuse sessions"));
+ parser.addHelpOption();
+ QCommandLineOption sessionOption(QStringList() << QLatin1String("session") << 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"));
+ parser.addOption(sessionOption);
+ parser.addOption(urlOption);
+ parser.addOption(pidOption);
+ parser.process(app);
+
+ if (!parser.isSet(sessionOption) || !parser.isSet(urlOption) || !parser.isSet(pidOption)) {
+ parser.showHelp();
+ return 1;
+ }
+
+ Gui window(parser.value(urlOption), parser.value(sessionOption), parser.value(pidOption).toInt());
window.show();
return QGuiApplication::exec();