diff options
author | Timothée Keller <timothee.keller@qt.io> | 2023-11-28 11:22:04 +0100 |
---|---|---|
committer | Timothée Keller <timothee.keller@qt.io> | 2023-11-28 19:59:48 +0100 |
commit | 0e528f2976a64d0348fe0bebfb97293eae5bac73 (patch) | |
tree | 441034eb2d7f10a799ffed1a7291501059d7b583 /src/tools/windeployqt/main.cpp | |
parent | 5aff671eea43c1c28990591a8e7d65af05496755 (diff) |
Windeployqt: Fix -v/--version option
While the version option was already there, it had no output attached
to it, and simply generated the whole help text. Make sure that if the
-v/--version option is set, only the tool version is outputted.
Fixes: QTBUG-119511
Pick-to: 6.6
Change-Id: I59ee620333c02eb0a031cd05ac3170216cd034fa
Reviewed-by: Oliver Wolff <oliver.wolff@qt.io>
Diffstat (limited to 'src/tools/windeployqt/main.cpp')
-rw-r--r-- | src/tools/windeployqt/main.cpp | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/src/tools/windeployqt/main.cpp b/src/tools/windeployqt/main.cpp index f3c579c56b..cc9a3f88dd 100644 --- a/src/tools/windeployqt/main.cpp +++ b/src/tools/windeployqt/main.cpp @@ -229,7 +229,8 @@ static QString msgFileDoesNotExist(const QString & file) enum CommandLineParseFlag { CommandLineParseError = 0x1, - CommandLineParseHelpRequested = 0x2 + CommandLineParseHelpRequested = 0x2, + CommandLineVersionRequested = 0x4 }; static QCommandLineOption createQMakeOption() @@ -330,7 +331,7 @@ static inline int parseArguments(const QStringList &arguments, QCommandLineParse "installation (e.g. <QT_DIR\\bin>) to the PATH variable and then run:\n windeployqt <path-to-app-binary>\n\n" "If your application uses Qt Quick, run:\n windeployqt --qmldir <path-to-app-qml-files> <path-to-app-binary>"_s); const QCommandLineOption helpOption = parser->addHelpOption(); - parser->addVersionOption(); + const QCommandLineOption versionOption = parser->addVersionOption(); QCommandLineOption dirOption(QStringLiteral("dir"), QStringLiteral("Use directory instead of binary directory."), @@ -520,6 +521,8 @@ static inline int parseArguments(const QStringList &arguments, QCommandLineParse const bool success = parser->parse(arguments); if (parser->isSet(helpOption)) return CommandLineParseHelpRequested; + if (parser->isSet(versionOption)) + return CommandLineVersionRequested; if (!success) { *errorMessage = parser->errorText(); return CommandLineParseError; @@ -1810,6 +1813,10 @@ int main(int argc, char **argv) const int result = parseArguments(QCoreApplication::arguments(), &parser, &options, &errorMessage); if (result & CommandLineParseError) std::wcerr << errorMessage << "\n\n"; + if (result & CommandLineVersionRequested) { + std::fputs(QT_VERSION_STR "\n", stdout); + return 0; + } if (result & CommandLineParseHelpRequested) std::fputs(qPrintable(helpText(parser, pluginInfo)), stdout); if (result & CommandLineParseError) |