ClangBackEnd: Use QCommandLineParser.

Output a proper usage message instead of a cryptic "wrong argument
count" when launching it from the shell for testing.

Change-Id: Iedb6b1062c9d246a514aefb05220942e4a6341df
Reviewed-by: Marco Bubke <marco.bubke@theqtcompany.com>
This commit is contained in:
Friedemann Kleint
2016-02-01 09:56:12 +01:00
parent 7114ee9149
commit f38d291339

View File

@@ -28,6 +28,7 @@
**
****************************************************************************/
#include <QCommandLineParser>
#include <QCoreApplication>
#include <QLoggingCategory>
@@ -35,6 +36,22 @@
#include <cmbmessages.h>
#include <clangipcserver.h>
QString processArguments(QCoreApplication &application)
{
QCommandLineParser parser;
parser.setApplicationDescription(QStringLiteral("Qt Creator Clang backend process."));
parser.addHelpOption();
parser.addVersionOption();
parser.addPositionalArgument(QStringLiteral("connection"), QStringLiteral("Connection"));
parser.process(application);
if (parser.positionalArguments().isEmpty())
parser.showHelp(1);
return parser.positionalArguments().first();
}
int main(int argc, char *argv[])
{
QLoggingCategory::setFilterRules(QStringLiteral("*.debug=false"));
@@ -46,10 +63,7 @@ int main(int argc, char *argv[])
QCoreApplication application(argc, argv);
if (application.arguments().count() != 2) {
qWarning() << "wrong argument count";
return 1;
}
const QString connection = processArguments(application);
ClangBackEnd::Messages::registerMessages();
@@ -57,7 +71,7 @@ int main(int argc, char *argv[])
clang_enableStackTraces();
ClangBackEnd::ClangIpcServer clangIpcServer;
ClangBackEnd::ConnectionServer connectionServer(application.arguments()[1]);
ClangBackEnd::ConnectionServer connectionServer(connection);
connectionServer.start();
connectionServer.setIpcServer(&clangIpcServer);