From 0f815936c9ffe506c1df0d489363d191785945a5 Mon Sep 17 00:00:00 2001 From: Tobias Hammer Date: Thu, 25 Jan 2024 08:49:22 +0100 Subject: [PATCH] Set working directory from cli (#402) Simplifies working from commandline when required files are in current directory. Signed-off-by: Tobias Hammer --- qdlt/qdltoptmanager.cpp | 6 ++++++ qdlt/qdltoptmanager.h | 2 ++ src/workingdirectory.cpp | 7 ++++++- 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/qdlt/qdltoptmanager.cpp b/qdlt/qdltoptmanager.cpp index d7fa1e9d..2905d2d0 100644 --- a/qdlt/qdltoptmanager.cpp +++ b/qdlt/qdltoptmanager.cpp @@ -328,6 +328,11 @@ void QDltOptManager::parse(QStringList *opt) } ++i; } + else if (str.compare("-w") == 0) + { + workingDirectory = opt->value(i+1); + ++i; + } else if(opt->at(i).endsWith(".dlt") || opt->at(i).endsWith(".DLT")) { if (convert == true) @@ -368,3 +373,4 @@ QString QDltOptManager::getConvertDestFile(){return convertDestFile;} QString QDltOptManager::getPluginName(){return pluginName;} QString QDltOptManager::getCommandName(){return commandName;} QStringList QDltOptManager::getCommandParams(){return commandParams;} +QString QDltOptManager::getWorkingDirectory() const { return workingDirectory; } diff --git a/qdlt/qdltoptmanager.h b/qdlt/qdltoptmanager.h index e3260a6b..57f6c4c9 100644 --- a/qdlt/qdltoptmanager.h +++ b/qdlt/qdltoptmanager.h @@ -62,6 +62,7 @@ class QDLT_EXPORT QDltOptManager QString getPluginName(); QString getCommandName(); QStringList getCommandParams(); + QString getWorkingDirectory() const; private: QDltOptManager(); @@ -85,6 +86,7 @@ class QDLT_EXPORT QDltOptManager QString pluginName; QString commandName; QStringList commandParams; + QString workingDirectory; }; #endif //QDLTOPTMANAGER_H diff --git a/src/workingdirectory.cpp b/src/workingdirectory.cpp index 6e6b5f85..46aeaac1 100644 --- a/src/workingdirectory.cpp +++ b/src/workingdirectory.cpp @@ -1,6 +1,7 @@ #include "workingdirectory.h" #include "qdltsettingsmanager.h" +#include "qdltoptmanager.h" // See workingdirectory.h for documentation. @@ -44,7 +45,11 @@ QString WorkingDirectory::getDirectory(WorkingDirectoryType type, QString extra) QString ret = ""; QString key = createKeyFor(type, extra); - if(type == WorkingDirectory::PluginConfig) + if (!QDltOptManager::getInstance()->getWorkingDirectory().isEmpty()) + { + ret = QDltOptManager::getInstance()->getWorkingDirectory(); + } + else if(type == WorkingDirectory::PluginConfig) { ret = QDltSettingsManager::getInstance()->value(key, "plugins/").toString(); }