add command-line parameter "debug"

This commit is contained in:
2025-10-01 14:36:28 +02:00
parent 559298331b
commit 67eeade609
3 changed files with 26 additions and 4 deletions

View File

@@ -67,11 +67,11 @@ int main(int argc, char **argv) {
//return 0;
/*
CommandLineParser parser;
parser.process(a);
parser.readSettings();
/*
QString repositoryUrl = parser.repositoryUrl();
QString plugInDir = parser.plugInDir();
QString plugInName = parser.plugInName();
@@ -80,6 +80,7 @@ int main(int argc, char **argv) {
QString psaTariffDir = parser.psaTariffDir();
QString psaDcDir = parser.dcDir();
QString iniFileName = parser.iniFileName();
bool debug = parser.debug();
bool const dryRun = parser.dryRun();
bool const noUpdatePsaHardware = parser.noUpdatePsaHardware();
bool const showYoctoVersion = parser.yoctoVersion();

View File

@@ -23,6 +23,7 @@ class CommandLineParser : public QCommandLineParser {
QString m_alwaysDownloadDC;
QString m_readDCVersion{"false"};
QString m_dcDir{"etc/dc/"};
QString m_debug{"false"};
qint64 m_ppid;
QCommandLineOption m_repositoryUrlOption;
@@ -43,6 +44,7 @@ class CommandLineParser : public QCommandLineParser {
QCommandLineOption m_dcDirectoryOption;
QCommandLineOption m_readDCVersionOption;
QCommandLineOption m_setPPid;
QCommandLineOption m_debugOption;
QCommandLineParser m_parser;
@@ -77,5 +79,6 @@ public:
bool alwaysDownloadDC();
bool readDCVersion();
QString dcDir();
bool debug();
};
#endif // COMMAND_LINE_PARSER_H_INCLUDED

View File

@@ -100,7 +100,12 @@ CommandLineParser::CommandLineParser()
QCommandLineOption(
QStringList() << "P" << "set-ppid",
QCoreApplication::translate("main", "Set pid of parent process."),
QCoreApplication::translate("main", "Set pid of parent process."))) {
QCoreApplication::translate("main", "Set pid of parent process.")))
, m_debugOption(
QCommandLineOption(
QStringList() << "debug" << "debug",
QCoreApplication::translate("main", "Set debug flag."),
QCoreApplication::translate("main", "Set debug flag."))) {
configure();
}
@@ -110,7 +115,7 @@ void CommandLineParser::configure() {
m_parser.addHelpOption();
m_parser.addVersionOption();
m_repositoryUrlOption.setDefaultValue("https://git.mimbach49.de/GerhardHoffmann");
m_repositoryUrlOption.setDefaultValue("https://ptu-config.atb-comm.de/ATB/");
m_parser.addOption(m_repositoryUrlOption);
m_iniFileDirectoryOption.setDefaultValue(QCoreApplication::applicationDirPath());
@@ -163,6 +168,9 @@ void CommandLineParser::configure() {
m_setPPid.setDefaultValue("-1");
m_parser.addOption(m_setPPid);
m_debugOption.setDefaultValue("false");
m_parser.addOption(m_debugOption);
}
void CommandLineParser::readSettings() {
@@ -180,7 +188,7 @@ void CommandLineParser::readSettings() {
for (QString const &key: keys) {
QVariant v = settings.value(key);
//qCritical() << "(" << __func__ << ":" << __LINE__ << ")"
// qCritical() << "(" << __func__ << ":" << __LINE__ << ")"
// << key << " -> " << v.toString();
if (key.contains("repository-url")) {
@@ -227,6 +235,9 @@ void CommandLineParser::readSettings() {
} else
if (key.contains("read-dc-version")) {
m_readDCVersion = (v.toBool() ? "true" : "false");
} else
if (key.contains("debug")) {
m_debug = (v.toBool() ? "true" : "false");
} else {
qCritical() << __PRETTY_FUNCTION__
<< key << " -> (UNKNOWN) " << v.toString();
@@ -288,6 +299,13 @@ bool CommandLineParser::readDCVersion() {
return m_readDCVersion == "false" ? false : true;
}
bool CommandLineParser::debug() {
if (m_parser.isSet(m_debugOption)) {
m_debug = m_parser.value(m_debugOption);
}
return m_debug == "false" ? false : true;
}
QString CommandLineParser::workingDir() {
if (m_parser.isSet(m_workingDirectoryOption)) {
m_workingDir = m_parser.value(m_workingDirectoryOption);