print version on --version switch

This commit is contained in:
fourtf 2019-10-07 18:57:33 +02:00
parent 05bcf22af4
commit 594c0fb255
4 changed files with 17 additions and 1 deletions

View file

@ -10,6 +10,10 @@ Args::Args(const QStringList &args)
{ {
this->crashRecovery = true; this->crashRecovery = true;
} }
else if (arg == "--version")
{
this->printVersion = true;
}
} }
} }

View file

@ -1,5 +1,7 @@
#pragma once #pragma once
#include <QStringList>
namespace chatterino { namespace chatterino {
/// Command line arguments passed to Chatterino. /// Command line arguments passed to Chatterino.
@ -8,6 +10,7 @@ class Args
public: public:
Args(const QStringList &args); Args(const QStringList &args);
bool printVersion{};
bool crashRecovery{}; bool crashRecovery{};
}; };

View file

@ -1,5 +1,6 @@
#pragma once #pragma once
#include <QString>
#include <QtGlobal> #include <QtGlobal>
#define CHATTERINO_VERSION "2.1.5" #define CHATTERINO_VERSION "2.1.5"

View file

@ -1,4 +1,6 @@
#include <QApplication> #include <QApplication>
#include <QDebug>
#include <QMessageBox>
#include <QStringList> #include <QStringList>
#include <memory> #include <memory>
@ -6,6 +8,7 @@
#include "RunGui.hpp" #include "RunGui.hpp"
#include "common/Args.hpp" #include "common/Args.hpp"
#include "common/Modes.hpp" #include "common/Modes.hpp"
#include "common/Version.hpp"
#include "singletons/Paths.hpp" #include "singletons/Paths.hpp"
#include "singletons/Settings.hpp" #include "singletons/Settings.hpp"
#include "util/IncognitoBrowser.hpp" #include "util/IncognitoBrowser.hpp"
@ -20,15 +23,19 @@ int main(int argc, char **argv)
auto args = QStringList(); auto args = QStringList();
std::transform(argv + 1, argv + argc, std::back_inserter(args), std::transform(argv + 1, argv + argc, std::back_inserter(args),
[&](auto s) { return s; }); [&](auto s) { return s; });
initArgs(args);
// run in gui mode or browser extension host mode // run in gui mode or browser extension host mode
if (shouldRunBrowserExtensionHost(args)) if (shouldRunBrowserExtensionHost(args))
{ {
runBrowserExtensionHost(); runBrowserExtensionHost();
} }
else if (getArgs().printVersion)
{
qInfo().noquote() << Version::getInstance().getFullVersion();
}
else else
{ {
initArgs(args);
Paths *paths{}; Paths *paths{};
try try
@ -60,4 +67,5 @@ int main(int argc, char **argv)
runGui(a, *paths, settings); runGui(a, *paths, settings);
} }
return 0;
} }