Output CLI error/info messages to the console on Windows

Fixes #1554
This commit is contained in:
Cameron Gutman 2025-04-04 22:23:17 -05:00
parent 48bcd725c9
commit c93f7e7385
2 changed files with 20 additions and 26 deletions

View File

@ -59,13 +59,6 @@ public:
void showMessage(QString message, MessageType type) const
{
#if defined(Q_OS_WIN32)
UINT flags = MB_OK | MB_TOPMOST | MB_SETFOREGROUND;
flags |= (type == Info ? MB_ICONINFORMATION : MB_ICONERROR);
QString title = "Moonlight";
MessageBoxW(nullptr, reinterpret_cast<const wchar_t *>(message.utf16()),
reinterpret_cast<const wchar_t *>(title.utf16()), flags);
#endif
message = message.endsWith('\n') ? message : message + '\n';
fputs(qPrintable(message), type == Info ? stdout : stderr);
}

View File

@ -588,12 +588,6 @@ int main(int argc, char *argv[])
}
#endif
GlobalCommandLineParser parser;
GlobalCommandLineParser::ParseResult commandLineParserResult = parser.parse(app.arguments());
switch (commandLineParserResult) {
case GlobalCommandLineParser::ListRequested:
// Don't log to the console since it will jumble the command output
s_SuppressVerboseOutput = true;
#ifdef Q_OS_WIN32
// If we don't have stdout or stderr handles (which will normally be the case
// since we're a /SUBSYSTEM:WINDOWS app), attach to our parent console and use
@ -613,6 +607,13 @@ int main(int argc, char *argv[])
}
}
#endif
GlobalCommandLineParser parser;
GlobalCommandLineParser::ParseResult commandLineParserResult = parser.parse(app.arguments());
switch (commandLineParserResult) {
case GlobalCommandLineParser::ListRequested:
// Don't log to the console since it will jumble the command output
s_SuppressVerboseOutput = true;
break;
default:
break;