diff --git a/CHANGELOG.md b/CHANGELOG.md index a9167f23..b26e0c8b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -31,6 +31,7 @@ - Minor: Removed experimental IRC support. (#5547) - Minor: Moderators can now see which mods start and cancel raids. (#5563) - Minor: The emote popup now reloads when Twitch emotes are reloaded. (#5580) +- Minor: Added `--login ` CLI argument to specify which account to start logged in as. (#5626) - Bugfix: Fixed tab move animation occasionally failing to start after closing a tab. (#5426, #5612) - Bugfix: If a network request errors with 200 OK, Qt's error code is now reported instead of the HTTP status. (#5378) - Bugfix: Fixed restricted users usernames not being clickable. (#5405) diff --git a/src/common/Args.cpp b/src/common/Args.cpp index eeebbfc2..795e1fa1 100644 --- a/src/common/Args.cpp +++ b/src/common/Args.cpp @@ -117,6 +117,13 @@ Args::Args(const QApplication &app, const Paths &paths) "safe-mode", "Starts Chatterino without loading Plugins and always " "show the settings button."); + QCommandLineOption loginOption( + "login", + "Starts Chatterino logged in as the account matching the supplied " + "username. If the supplied username does not match any account " + "Chatterino starts logged in as anonymous.", + "username"); + // Channel layout auto channelLayout = QCommandLineOption( {"c", "channels"}, @@ -142,6 +149,7 @@ Args::Args(const QApplication &app, const Paths &paths) parentWindowIdOption, verboseOption, safeModeOption, + loginOption, channelLayout, activateOption, }); @@ -197,6 +205,11 @@ Args::Args(const QApplication &app, const Paths &paths) this->safeMode = true; } + if (parser.isSet(loginOption)) + { + this->initialLogin = parser.value(loginOption); + } + if (parser.isSet(activateOption)) { this->activateChannel = @@ -206,6 +219,7 @@ Args::Args(const QApplication &app, const Paths &paths) this->currentArguments_ = extractCommandLine(parser, { verboseOption, safeModeOption, + loginOption, channelLayout, activateOption, }); diff --git a/src/common/Args.hpp b/src/common/Args.hpp index b3eeb20f..cac8fb67 100644 --- a/src/common/Args.hpp +++ b/src/common/Args.hpp @@ -60,6 +60,7 @@ public: bool dontLoadMainWindow{}; std::optional customChannelLayout; std::optional activateChannel; + std::optional initialLogin; bool verbose{}; bool safeMode{}; diff --git a/src/providers/twitch/TwitchAccountManager.cpp b/src/providers/twitch/TwitchAccountManager.cpp index 3939bea1..7f4ed78a 100644 --- a/src/providers/twitch/TwitchAccountManager.cpp +++ b/src/providers/twitch/TwitchAccountManager.cpp @@ -1,5 +1,7 @@ #include "providers/twitch/TwitchAccountManager.hpp" +#include "Application.hpp" +#include "common/Args.hpp" #include "common/Common.hpp" #include "common/QLogging.hpp" #include "providers/twitch/api/Helix.hpp" @@ -144,6 +146,11 @@ void TwitchAccountManager::reloadUsers() void TwitchAccountManager::load() { + if (getApp()->getArgs().initialLogin.has_value()) + { + this->currentUsername = getApp()->getArgs().initialLogin.value(); + } + this->reloadUsers(); this->currentUsername.connect([this](const QString &newUsername) {