From 6bb46e165c5b14b025256daac41e25ebff3b8104 Mon Sep 17 00:00:00 2001 From: Gerhard Hoffmann Date: Thu, 6 Jul 2023 14:12:41 +0200 Subject: [PATCH] Add handling of VERSION. Add test-mode. --- main.cpp | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/main.cpp b/main.cpp index f30e590..fee9594 100644 --- a/main.cpp +++ b/main.cpp @@ -36,9 +36,9 @@ class hwinf; static void doWork(hwinf *hw, QString update_ctrl_file, - QString workingDir, bool maintenanceMode) { + QString workingDir, bool maintenanceMode, bool testMode) { std::this_thread::sleep_for(std::chrono::milliseconds(2000)); - Update update(hw, update_ctrl_file, workingDir, maintenanceMode); + Update update(hw, update_ctrl_file, workingDir, maintenanceMode, testMode); update.doUpdate(); std::this_thread::sleep_for(std::chrono::milliseconds(2000)); QCoreApplication::quit(); @@ -54,7 +54,7 @@ int main(int argc, char *argv[]) { QApplication a(argc, argv); QApplication::setApplicationName("ATBUpdateTool"); - QApplication::setApplicationVersion("1.0"); + QApplication::setApplicationVersion(APP_VERSION); if (!messageHandlerInstalled()) { // change internal qt-QDebug-handling atbInstallMessageHandler(atbDebugOutput); @@ -92,6 +92,12 @@ int main(int argc, char *argv[]) { QCoreApplication::translate("main", "Maintenance mode for underlying script")); parser.addOption(maintenanceOption); + // test-mode: edit the file update_log.csv and execute the commands + // contained in it. Do not call the update-script. + QCommandLineOption testOption("t", + QCoreApplication::translate("main", "Test mode for ATBUpdateTool")); + parser.addOption(testOption); + // TODO: // add some additional parameters // --dry-run @@ -106,6 +112,7 @@ int main(int argc, char *argv[]) { QString plugInName = parser.value(pluginNameOption); QString workingDir = parser.value(workingDirectoryOption); bool maintenanceMode = parser.isSet(maintenanceOption); + bool testMode = parser.isSet(testOption); QString const rtPath = QCoreApplication::applicationDirPath(); if (plugInDir == pluginDefault) { @@ -121,6 +128,7 @@ int main(int argc, char *argv[]) { qInfo() << "plugInName" << "=" << plugInName; qInfo() << "workingDir" << "=" << workingDir; qInfo() << "maintenanceMode" << "=" << maintenanceMode; + qInfo() << "testMode" << "=" << testMode; // before loading the library, delete all possible shared memory segments #if defined Q_OS_LINUX || defined Q_OS_UNIX @@ -130,10 +138,10 @@ int main(int argc, char *argv[]) { #endif hwinf *hw = Update::loadDCPlugin(QDir(plugInDir), plugInName); - hw->dc_autoRequest(false); + // 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, maintenanceMode); + std::thread t(doWork, hw, update_ctrl_file, workingDir, maintenanceMode, testMode); int ret = a.exec(); t.join();