fix: properly handle CLI arguments (#2368)

Fix CLI arguments not being respected. This happened due to the addition of category-based logging (--help, --version) and changes to the window loading ( --channels), respectively.

When handling --channels, I took the liberty to refactor the previous version of window description (which relied on generating JSON) to directly building the WindowLayout.
This commit is contained in:
Leon Richardt
2021-01-23 16:26:42 +01:00
committed by GitHub
parent 55dd09a9f0
commit 1b75dc1e2c
6 changed files with 140 additions and 81 deletions
+33 -34
View File
@@ -27,6 +27,33 @@ int main(int argc, char **argv)
QCoreApplication::setApplicationVersion(CHATTERINO_VERSION);
QCoreApplication::setOrganizationDomain("https://www.chatterino.com");
Paths *paths{};
try
{
paths = new Paths;
}
catch (std::runtime_error &error)
{
QMessageBox box;
if (Modes::instance().isPortable)
{
box.setText(
error.what() +
QStringLiteral(
"\n\nInfo: Portable mode requires the application to "
"be in a writeable location. If you don't want "
"portable mode reinstall the application. "
"https://chatterino.com."));
}
else
{
box.setText(error.what());
}
box.exec();
return 1;
}
initArgs(a);
// run in gui mode or browser extension host mode
@@ -37,13 +64,12 @@ int main(int argc, char **argv)
else if (getArgs().printVersion)
{
auto version = Version::instance();
qCInfo(chatterinoMain).noquote()
<< QString("%1 (commit %2%3)")
.arg(version.fullVersion())
.arg(version.commitHash())
.arg(Modes::instance().isNightly
? ", " + version.dateOfBuild()
: "");
qInfo().noquote() << QString("%1 (commit %2%3)")
.arg(version.fullVersion())
.arg(version.commitHash())
.arg(Modes::instance().isNightly
? ", " + version.dateOfBuild()
: "");
}
else
{
@@ -51,33 +77,6 @@ int main(int argc, char **argv)
Helix::initialize();
Kraken::initialize();
Paths *paths{};
try
{
paths = new Paths;
}
catch (std::runtime_error &error)
{
QMessageBox box;
if (Modes::instance().isPortable)
{
box.setText(
error.what() +
QStringLiteral(
"\n\nInfo: Portable mode requires the application to "
"be in a writeable location. If you don't want "
"portable mode reinstall the application. "
"https://chatterino.com."));
}
else
{
box.setText(error.what());
}
box.exec();
return 1;
}
Settings settings(paths->settingsDirectory);
runGui(a, *paths, settings);