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;
}
else if (arg == "--version")
{
this->printVersion = true;
}
}
}

View file

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

View file

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

View file

@ -1,4 +1,6 @@
#include <QApplication>
#include <QDebug>
#include <QMessageBox>
#include <QStringList>
#include <memory>
@ -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;
}