From d8565f987dab41cf98b689058826d522d49bc265 Mon Sep 17 00:00:00 2001
From: "A. Wilcox" <AWilcox@Wilcox-Tech.com>
Date: Mon, 10 Feb 2020 11:06:40 -0600
Subject: Qt Runner: Handle command line arguments, including --automatic

---
 ui/qt5/runner/main.cc | 28 +++++++++++++++++++++++++++-
 1 file changed, 27 insertions(+), 1 deletion(-)

(limited to 'ui')

diff --git a/ui/qt5/runner/main.cc b/ui/qt5/runner/main.cc
index bac429d..a545982 100644
--- a/ui/qt5/runner/main.cc
+++ b/ui/qt5/runner/main.cc
@@ -11,6 +11,7 @@
  */
 
 #include <QApplication>
+#include <QCommandLineParser>
 #include <QIcon>
 #include <QLibraryInfo>
 #include <QTranslator>
@@ -19,6 +20,9 @@
 
 int main(int argc, char *argv[]) {
     QApplication app(argc, argv);
+    app.setOrganizationName("Adélie Linux");
+    app.setApplicationName("Horizon Runner GUI");
+    app.setApplicationVersion(VERSTR);
 
     QString translatorFileName = QLatin1String("qt_");
     translatorFileName += QLocale::system().name();
@@ -32,7 +36,29 @@ int main(int argc, char *argv[]) {
 
     app.setWindowIcon(QIcon(":/horizon-256.png"));
 
-    ExecutorWizard wizard;
+    QCommandLineParser parser;
+    parser.setApplicationDescription(app.tr("Executes a HorizonScript with graphical progress indication."));
+    QCommandLineOption help = parser.addHelpOption();
+    QCommandLineOption version = parser.addVersionOption();
+    QCommandLineOption automatic("automatic", app.tr("Runs the Executor in Automatic mode.  After installation, the system will be restarted automatically."));
+    parser.addOption(automatic);
+
+    if(!parser.parse(app.arguments())) {
+        parser.showHelp(1);
+        return 1;
+    }
+
+    if(parser.isSet(help)) {
+        parser.showHelp();
+        return 0;
+    }
+
+    if(parser.isSet(version)) {
+        parser.showVersion();
+        return 0;
+    }
+
+    ExecutorWizard wizard(nullptr, parser.isSet(automatic));
     wizard.show();
 
     return app.exec();
-- 
cgit v1.2.3-70-g09d2