qmlls: add --version command line parameter

Add a command line parameter to print the qmlls version, required by
qmlls clients to check the version of downloaded qmlls binaries.

Fixes: QTBUG-132692
Change-Id: I7903f6859b6da2f3849a899e46fe4c5ce1cf4c42
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
This commit is contained in:
Sami Shalayel 2025-03-20 11:01:28 +01:00
parent 95fbd1e9fc
commit e28947f150
2 changed files with 14 additions and 2 deletions

View File

@ -213,8 +213,6 @@ int qmllsMain(int argv, char *argc[])
QHashSeed::setDeterministicGlobalSeed();
QCoreApplication app(argv, argc);
QCoreApplication::setApplicationName("qmlls"_L1);
QCoreApplication::setApplicationVersion(QLatin1String(QT_VERSION_STR));
QCommandLineParser parser;
QQmlToolingSettings settings("qmlls"_L1);
@ -289,8 +287,17 @@ int qmllsMain(int argv, char *argc[])
const QString qmlImportNoDefaultSetting = "DisableDefaultImports"_L1;
settings.addOption(qmlImportNoDefaultSetting, false);
// we can't use parser.addVersionOption() because we already have one '-v' option for verbose...
QCommandLineOption versionOption("version"_L1, "Displays version information."_L1);
parser.addOption(versionOption);
parser.process(app);
if (parser.isSet(versionOption)) {
parser.showVersion();
return EXIT_SUCCESS;
}
if (parser.isSet(writeDefaultsOption)) {
return settings.writeDefaults() ? 0 : 1;
}

View File

@ -2,6 +2,7 @@
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
#include <private/qmllsmain_p.h>
#include <QtCore/qcoreapplication.h>
// To debug:
//
@ -27,7 +28,11 @@
// * statup can be slowed down to have the time to attach via the
// -w <nSeconds> flag.
using namespace Qt::StringLiterals;
int main(int argv, char *argc[])
{
QCoreApplication::setApplicationVersion(QLatin1String(QT_VERSION_STR));
QCoreApplication::setApplicationName("qmlls"_L1);
return QmlLsp::qmllsMain(argv, argc);
}