diff --git a/chatterino.pro b/chatterino.pro index 0230bba30..56857ea0a 100644 --- a/chatterino.pro +++ b/chatterino.pro @@ -76,6 +76,7 @@ SOURCES += \ src/Application.cpp \ src/autogenerated/ResourcesAutogen.cpp \ src/BrowserExtension.cpp \ + src/common/Args.cpp \ src/common/Channel.cpp \ src/common/ChannelChatters.cpp \ src/common/CompletionModel.cpp \ @@ -233,6 +234,7 @@ HEADERS += \ src/autogenerated/ResourcesAutogen.hpp \ src/BrowserExtension.hpp \ src/common/Aliases.hpp \ + src/common/Args.hpp \ src/common/Atomic.hpp \ src/common/Channel.hpp \ src/common/ChannelChatters.hpp \ diff --git a/src/Application.cpp b/src/Application.cpp index a5c7e83ef..c4e12a263 100644 --- a/src/Application.cpp +++ b/src/Application.cpp @@ -2,6 +2,7 @@ #include +#include "common/Args.hpp" #include "controllers/accounts/AccountController.hpp" #include "controllers/commands/CommandController.hpp" #include "controllers/highlights/HighlightController.hpp" diff --git a/src/common/Args.cpp b/src/common/Args.cpp new file mode 100644 index 000000000..ab2704f80 --- /dev/null +++ b/src/common/Args.cpp @@ -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 diff --git a/src/common/Args.hpp b/src/common/Args.hpp new file mode 100644 index 000000000..c27932c81 --- /dev/null +++ b/src/common/Args.hpp @@ -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 diff --git a/src/main.cpp b/src/main.cpp index 6cce245e2..7809a03e9 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -26,6 +26,7 @@ int main(int argc, char **argv) } else { + initArgs(args); Paths paths; Settings settings(paths.settingsDirectory);