summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/config.cpp22
-rw-r--r--src/config.h3
-rw-r--r--src/main.cpp5
3 files changed, 29 insertions, 1 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";
+ }
+ }
+}
diff --git a/src/config.h b/src/config.h
index 872836d..f1a20ea 100644
--- a/src/config.h
+++ b/src/config.h
@@ -2,7 +2,6 @@
#define CONFIG_H
#include <QCoreApplication>
-#include <QList>
struct ConfigOption;
@@ -34,10 +33,12 @@ public:
static const ConfigOption* const TEMPLATE_MODE;
static const ConfigOption* const AUTOSTART_UUID;
static const ConfigOption* const NO_VTX;
+ static const ConfigOption* const DUMP_CONFIG;
static bool init(const QCoreApplication& app, const ConfigOption* const configFile);
static QString get(const ConfigOption* const option);
static bool isSet(const ConfigOption* const option);
+ static void dump();
private:
Config() {}
diff --git a/src/main.cpp b/src/main.cpp
index 3390101..4c0592f 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -30,6 +30,11 @@ int main(int argc, char *argv[]) {
return 1;
}
+ if (Config::isSet(Config::DUMP_CONFIG)) {
+ Config::dump();
+ return 0;
+ }
+
if (Config::isSet(Config::INSECURE)) {
qDebug() << "Warning: Certificate validation disabled";
QSslConfiguration sslConf = QSslConfiguration::defaultConfiguration();