mirror of
https://github.com/Chatterino/chatterino2.git
synced 2024-11-13 19:49:51 +01:00
added class containing program arguments
This commit is contained in:
parent
456065f508
commit
7e555843ca
|
@ -76,6 +76,7 @@ SOURCES += \
|
||||||
src/Application.cpp \
|
src/Application.cpp \
|
||||||
src/autogenerated/ResourcesAutogen.cpp \
|
src/autogenerated/ResourcesAutogen.cpp \
|
||||||
src/BrowserExtension.cpp \
|
src/BrowserExtension.cpp \
|
||||||
|
src/common/Args.cpp \
|
||||||
src/common/Channel.cpp \
|
src/common/Channel.cpp \
|
||||||
src/common/ChannelChatters.cpp \
|
src/common/ChannelChatters.cpp \
|
||||||
src/common/CompletionModel.cpp \
|
src/common/CompletionModel.cpp \
|
||||||
|
@ -233,6 +234,7 @@ HEADERS += \
|
||||||
src/autogenerated/ResourcesAutogen.hpp \
|
src/autogenerated/ResourcesAutogen.hpp \
|
||||||
src/BrowserExtension.hpp \
|
src/BrowserExtension.hpp \
|
||||||
src/common/Aliases.hpp \
|
src/common/Aliases.hpp \
|
||||||
|
src/common/Args.hpp \
|
||||||
src/common/Atomic.hpp \
|
src/common/Atomic.hpp \
|
||||||
src/common/Channel.hpp \
|
src/common/Channel.hpp \
|
||||||
src/common/ChannelChatters.hpp \
|
src/common/ChannelChatters.hpp \
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
|
|
||||||
#include <atomic>
|
#include <atomic>
|
||||||
|
|
||||||
|
#include "common/Args.hpp"
|
||||||
#include "controllers/accounts/AccountController.hpp"
|
#include "controllers/accounts/AccountController.hpp"
|
||||||
#include "controllers/commands/CommandController.hpp"
|
#include "controllers/commands/CommandController.hpp"
|
||||||
#include "controllers/highlights/HighlightController.hpp"
|
#include "controllers/highlights/HighlightController.hpp"
|
||||||
|
|
30
src/common/Args.cpp
Normal file
30
src/common/Args.cpp
Normal file
|
@ -0,0 +1,30 @@
|
||||||
|
#include "Args.hpp"
|
||||||
|
|
||||||
|
namespace chatterino {
|
||||||
|
|
||||||
|
Args::Args(const QStringList &args)
|
||||||
|
{
|
||||||
|
for (auto &&arg : args)
|
||||||
|
{
|
||||||
|
if (arg == "--crash-recovery")
|
||||||
|
{
|
||||||
|
this->crashRecovery = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static Args *instance = nullptr;
|
||||||
|
|
||||||
|
void initArgs(const QStringList &args)
|
||||||
|
{
|
||||||
|
instance = new Args(args);
|
||||||
|
}
|
||||||
|
|
||||||
|
const Args &getArgs()
|
||||||
|
{
|
||||||
|
assert(instance);
|
||||||
|
|
||||||
|
return *instance;
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace chatterino
|
17
src/common/Args.hpp
Normal file
17
src/common/Args.hpp
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
namespace chatterino {
|
||||||
|
|
||||||
|
/// Command line arguments passed to Chatterino.
|
||||||
|
class Args
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
Args(const QStringList &args);
|
||||||
|
|
||||||
|
bool crashRecovery{};
|
||||||
|
};
|
||||||
|
|
||||||
|
void initArgs(const QStringList &args);
|
||||||
|
const Args &getArgs();
|
||||||
|
|
||||||
|
} // namespace chatterino
|
|
@ -26,6 +26,7 @@ int main(int argc, char **argv)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
initArgs(args);
|
||||||
Paths paths;
|
Paths paths;
|
||||||
Settings settings(paths.settingsDirectory);
|
Settings settings(paths.settingsDirectory);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue