fix: Error text is not shown for Qt CLI parser
This commit is contained in:
parent
66e201c8ef
commit
4e2ad25fc1
1 changed files with 10 additions and 4 deletions
|
|
@ -36,6 +36,8 @@ using namespace deskflow::gui;
|
||||||
bool checkMacAssistiveDevices();
|
bool checkMacAssistiveDevices();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
const static auto kHeader = QStringLiteral("%1: %2\n").arg(kAppName, kDisplayVersion);
|
||||||
|
|
||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
#if defined(Q_OS_UNIX) && defined(QT_DEBUG)
|
#if defined(Q_OS_UNIX) && defined(QT_DEBUG)
|
||||||
|
|
@ -63,15 +65,19 @@ int main(int argc, char *argv[])
|
||||||
parser.addOption(resetOption);
|
parser.addOption(resetOption);
|
||||||
parser.parse(QCoreApplication::arguments());
|
parser.parse(QCoreApplication::arguments());
|
||||||
|
|
||||||
const auto header = QStringLiteral("%1: %2\n").arg(kAppName, kDisplayVersion);
|
if (!parser.errorText().isEmpty()) {
|
||||||
if (parser.isSet(helpOption) || !parser.unknownOptionNames().isEmpty() || !parser.errorText().isEmpty()) {
|
qCritical().noquote() << parser.errorText() << "\nUse --help for more information.";
|
||||||
QTextStream(stdout) << header << QStringLiteral(" %1\n\n").arg(kAppDescription)
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (parser.isSet(helpOption)) {
|
||||||
|
QTextStream(stdout) << kHeader << QStringLiteral(" %1\n\n").arg(kAppDescription)
|
||||||
<< parser.helpText().replace(QApplication::applicationFilePath(), kAppId);
|
<< parser.helpText().replace(QApplication::applicationFilePath(), kAppId);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (parser.isSet(versionOption)) {
|
if (parser.isSet(versionOption)) {
|
||||||
QTextStream(stdout) << header << kCopyright << Qt::endl;
|
QTextStream(stdout) << kHeader << kCopyright << Qt::endl;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue