From 079a6910dda4e8ddc87b5785dac7a07818727341 Mon Sep 17 00:00:00 2001 From: Gerhard Hoffmann Date: Tue, 20 Jun 2023 16:08:42 +0200 Subject: [PATCH] Added flag for maintenance-mode --- main.cpp | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/main.cpp b/main.cpp index 704fc9c..4131be2 100644 --- a/main.cpp +++ b/main.cpp @@ -35,9 +35,10 @@ #endif class hwinf; -static void doWork(hwinf *hw, QString update_ctrl_file, QString workingDir) { +static void doWork(hwinf *hw, QString update_ctrl_file, + QString workingDir, bool maintenanceMode) { std::this_thread::sleep_for(std::chrono::milliseconds(2000)); - Update update(hw, update_ctrl_file, workingDir); + Update update(hw, update_ctrl_file, workingDir, maintenanceMode); update.doUpdate(); std::this_thread::sleep_for(std::chrono::milliseconds(2000)); QCoreApplication::quit(); @@ -87,11 +88,16 @@ int main(int argc, char *argv[]) { workingDirectoryOption.setDefaultValue(workingDirectoryDefault); parser.addOption(workingDirectoryOption); + QCommandLineOption maintenanceOption("m", + QCoreApplication::translate("main", "Maintenance mode for underlying script")); + parser.addOption(maintenanceOption); + // Process the actual command line arguments given by the user parser.process(a); QString plugInDir = parser.value(pluginDirectoryOption); QString plugInName = parser.value(pluginNameOption); QString workingDir = parser.value(workingDirectoryOption); + bool maintenanceMode = parser.isSet(maintenanceOption); QString const rtPath = QCoreApplication::applicationDirPath(); if (plugInDir == pluginDefault) { @@ -106,6 +112,7 @@ int main(int argc, char *argv[]) { qInfo() << "plugInDir" << "=" << plugInDir; qInfo() << "plugInName" << "=" << plugInName; qInfo() << "workingDir" << "=" << workingDir; + qInfo() << "maintenanceMode" << "=" << maintenanceMode; // before loading the library, delete all possible shared memory segments #if defined Q_OS_LINUX || defined Q_OS_UNIX @@ -118,7 +125,7 @@ int main(int argc, char *argv[]) { hw->dc_autoRequest(false); QString const update_ctrl_file = "/opt/app/tools/atbupdate/update_log.csv"; - std::thread t(doWork, hw, update_ctrl_file, workingDir); + std::thread t(doWork, hw, update_ctrl_file, workingDir, maintenanceMode); int ret = a.exec(); t.join();