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 Change-Id: I59ee620333c02eb0a031cd05ac3170216cd034fa Reviewed-by: Oliver Wolff <oliver.wolff@qt.io> (cherry picked from commit 0e528f2976a64d0348fe0bebfb97293eae5bac73) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
parent
bd46f7a5ad
commit
8b9cd97eb9
@ -228,7 +228,8 @@ static QString msgFileDoesNotExist(const QString & file)
|
||||
|
||||
enum CommandLineParseFlag {
|
||||
CommandLineParseError = 0x1,
|
||||
CommandLineParseHelpRequested = 0x2
|
||||
CommandLineParseHelpRequested = 0x2,
|
||||
CommandLineVersionRequested = 0x4
|
||||
};
|
||||
|
||||
static QCommandLineOption createQMakeOption()
|
||||
@ -329,7 +330,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."),
|
||||
@ -515,6 +516,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;
|
||||
@ -1797,6 +1800,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)
|
||||
|
Loading…
x
Reference in New Issue
Block a user