Commit f38d2913 authored by Friedemann Kleint's avatar Friedemann Kleint
Browse files

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: default avatarMarco Bubke <marco.bubke@theqtcompany.com>
parent 7114ee91
......@@ -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);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment