diff --git a/src/common/Args.cpp b/src/common/Args.cpp index ab2704f80..0eaf5b355 100644 --- a/src/common/Args.cpp +++ b/src/common/Args.cpp @@ -10,6 +10,10 @@ Args::Args(const QStringList &args) { this->crashRecovery = true; } + else if (arg == "--version") + { + this->printVersion = true; + } } } diff --git a/src/common/Args.hpp b/src/common/Args.hpp index c27932c81..cde9538bf 100644 --- a/src/common/Args.hpp +++ b/src/common/Args.hpp @@ -1,5 +1,7 @@ #pragma once +#include + namespace chatterino { /// Command line arguments passed to Chatterino. @@ -8,6 +10,7 @@ class Args public: Args(const QStringList &args); + bool printVersion{}; bool crashRecovery{}; }; diff --git a/src/common/Version.hpp b/src/common/Version.hpp index 75b6b1fee..e531aeabc 100644 --- a/src/common/Version.hpp +++ b/src/common/Version.hpp @@ -1,5 +1,6 @@ #pragma once +#include #include #define CHATTERINO_VERSION "2.1.5" diff --git a/src/main.cpp b/src/main.cpp index c2c4d9ab6..45a2e2b45 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1,4 +1,6 @@ #include +#include +#include #include #include @@ -6,6 +8,7 @@ #include "RunGui.hpp" #include "common/Args.hpp" #include "common/Modes.hpp" +#include "common/Version.hpp" #include "singletons/Paths.hpp" #include "singletons/Settings.hpp" #include "util/IncognitoBrowser.hpp" @@ -20,15 +23,19 @@ int main(int argc, char **argv) auto args = QStringList(); std::transform(argv + 1, argv + argc, std::back_inserter(args), [&](auto s) { return s; }); + initArgs(args); // run in gui mode or browser extension host mode if (shouldRunBrowserExtensionHost(args)) { runBrowserExtensionHost(); } + else if (getArgs().printVersion) + { + qInfo().noquote() << Version::getInstance().getFullVersion(); + } else { - initArgs(args); Paths *paths{}; try @@ -60,4 +67,5 @@ int main(int argc, char **argv) runGui(a, *paths, settings); } + return 0; }