summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFriedemann Kleint <Friedemann.Kleint@theqtcompany.com>2016-02-01 09:56:12 +0100
committerFriedemann Kleint <Friedemann.Kleint@theqtcompany.com>2016-02-01 12:29:07 +0000
commitf38d29133956c4196fbfd66895f3a31fad5f9948 (patch)
tree3650443dbbfb73c433e4e7773fdc411065bed636
parent7114ee9149f825ba5f75236e61f3c0c0c540d340 (diff)
downloadqt-creator-f38d29133956c4196fbfd66895f3a31fad5f9948.tar.gz
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>
-rw-r--r--src/tools/clangbackend/clangbackendmain.cpp24
1 files changed, 19 insertions, 5 deletions
diff --git a/src/tools/clangbackend/clangbackendmain.cpp b/src/tools/clangbackend/clangbackendmain.cpp
index 33a6c1660e..95b4931361 100644
--- a/src/tools/clangbackend/clangbackendmain.cpp
+++ b/src/tools/clangbackend/clangbackendmain.cpp
@@ -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);