Blob Blame History Raw
From c730da8f9766250a4a03ad2b8d3826b3c9851593 Mon Sep 17 00:00:00 2001
From: Shawn Rutledge <shawn.rutledge@qt.io>
Date: Tue, 16 May 2023 07:59:46 +0200
Subject: [PATCH 23/30] qml tool: Use QCommandLineParser::process() rather than
 parse()

This handles the --version, --help and --help-all options.
Apparently there's no other way to handle --help-all, because
addHelpOption() adds two options but only returns one of them.
Amends bb6602bca2b20d98f24320b10c7a039e605c9a05

Fixes: QTBUG-100678
Pick-to: 6.2 6.5 5.15
Change-Id: Iddd1ba2dae975d7256935d8d357e2f3ac6c013d6
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
(cherry picked from commit e5007fcc43af6751c72ec970eed11df5fdb8638e)

* asturmlechner 2023-05-18: Resolve conflict with dev branch commit
  a15472716dbef63f1e5ad27ee412c2a2408b44e2
---
 tools/qml/main.cpp | 13 +++----------
 1 file changed, 3 insertions(+), 10 deletions(-)

diff --git a/tools/qml/main.cpp b/tools/qml/main.cpp
index beeec88f07..2cb7653d65 100644
--- a/tools/qml/main.cpp
+++ b/tools/qml/main.cpp
@@ -446,8 +446,8 @@ int main(int argc, char *argv[])
     QCommandLineParser parser;
     parser.setSingleDashWordOptionMode(QCommandLineParser::ParseAsLongOptions);
     parser.setOptionsAfterPositionalArgumentsMode(QCommandLineParser::ParseAsPositionalArguments);
-    const QCommandLineOption helpOption = parser.addHelpOption();
-    const QCommandLineOption versionOption = parser.addVersionOption();
+    parser.addHelpOption();
+    parser.addVersionOption();
 #ifdef QT_GUI_LIB
     QCommandLineOption apptypeOption(QStringList() << QStringLiteral("a") << QStringLiteral("apptype"),
         QCoreApplication::translate("main", "Select which application class to use. Default is gui."),
@@ -522,14 +522,7 @@ int main(int argc, char *argv[])
     parser.addPositionalArgument("args",
         QCoreApplication::translate("main", "Arguments after '--' are ignored, but passed through to the application.arguments variable in QML."), "[-- args...]");
 
-    if (!parser.parse(QCoreApplication::arguments())) {
-        qWarning() << parser.errorText();
-        exit(1);
-    }
-    if (parser.isSet(versionOption))
-        parser.showVersion();
-    if (parser.isSet(helpOption))
-        parser.showHelp();
+    parser.process(*app);
     if (parser.isSet(listConfOption))
         listConfFiles();
     if (applicationType == QmlApplicationTypeUnknown) {
-- 
2.44.0