summaryrefslogtreecommitdiffstats
path: root/src/config.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/config.cpp')
-rw-r--r--src/config.cpp22
1 files changed, 22 insertions, 0 deletions
diff --git a/src/config.cpp b/src/config.cpp
index 1689b00..d70b504 100644
--- a/src/config.cpp
+++ b/src/config.cpp
@@ -6,9 +6,11 @@
#include <QCommandLineParser>
#include <QSettings>
#include <QDebug>
+#include <QList>
static QCommandLineParser parser;
static QSettings* configFile = nullptr;
+static QList<ConfigOption*> allOptions;
static inline QStringList combine(const QString &a, const QString &b)
{
@@ -34,6 +36,7 @@ struct ConfigOption
if (!cmdLine.names().isEmpty()) {
parser.addOption(cmdLine);
}
+ allOptions.append(this);
}
};
@@ -62,6 +65,7 @@ const ConfigOption* const Config::LOCATION_MODE = new ConfigOption("", "location
const ConfigOption* const Config::TEMPLATE_MODE = new ConfigOption("", "template-mode", "template-mode", "mode", "BUMP", "Whether to BUMP entries marked as template, or IGNORE the flag");
const ConfigOption* const Config::AUTOSTART_UUID = new ConfigOption("", "start-uuid", "start-uuid", "uuid", "", "Immediately launch session with given uuid/name");
const ConfigOption* const Config::NO_VTX = new ConfigOption("", "no-vtx", "no-vtx", "", "0", "Fade all VM sessions that would require VTX/SVM CPU capabilities");
+const ConfigOption* const Config::DUMP_CONFIG = new ConfigOption("", "dump-config", "", "", "", "Dump effective configuration (config file plus command line options) to stdout");
QString Config::get(const ConfigOption* const option)
@@ -113,3 +117,21 @@ bool Config::init(const QCoreApplication& app, const ConfigOption* const configF
return true;
}
+void Config::dump()
+{
+ QTextStream ts(stdout);
+ for (ConfigOption *c : allOptions) {
+ if (c->iniKey.isEmpty()) // Not configurable by config
+ continue;
+ QString val = get(c);
+ if (c->withArgument) {
+ if (c->defaultValue.isEmpty() && val.isEmpty()) // Defaults to empty, current value is empty, skip
+ continue;
+ ts << c->iniKey << "=" << val << "\n";
+ } else {
+ if (!isSet(c)) // Bool argument not set, default would be false anyways, skip
+ continue;
+ ts << c->iniKey << "=true\n";
+ }
+ }
+}