From 9cc5b2b7d242f4e94f87a393d7e851040ee88990 Mon Sep 17 00:00:00 2001 From: Mattijs Korpershoek Date: Fri, 7 Mar 2014 16:36:18 +0100 Subject: Implemented -h command for test-platform For new users, it was not very clear that you had to give an .xml to the test-platform executable This patch implements -h an explicits that --- test/test-platform/main.cpp | 29 +++++++++++++++++++++++------ 1 file changed, 23 insertions(+), 6 deletions(-) (limited to 'test') diff --git a/test/test-platform/main.cpp b/test/test-platform/main.cpp index 129224a..a3f50be 100644 --- a/test/test-platform/main.cpp +++ b/test/test-platform/main.cpp @@ -153,12 +153,27 @@ static bool startDaemonTestPlatform(const char *filePath, int portNumber, string } } -static void usage() +static void showUsage() { - cerr << "Invalid arguments: test-platform [-d] [port number, default " + cerr << "test-platform [-dh] [port number, default " << iDefaultPortNumber << "]" << endl; } +static void showInvalidUsage() +{ + cerr << "Invalid arguments: "; + showUsage(); +} + +static void showHelp() +{ + showUsage(); + cerr << " must be a valid .xml file, oftenly ParameterFrameworkConfiguration.xml" << endl; + cerr << "Arguments:" << endl + << " -d starts as a deamon" << endl + << " -h display this help and exit" << endl; +} + int main(int argc, char *argv[]) { // Option found by call to getopt() @@ -174,15 +189,17 @@ int main(int argc, char *argv[]) int indexFilePath = 1; // Handle the -d option - while ((opt = getopt(argc, argv, "d")) != -1) { + while ((opt = getopt(argc, argv, "dh")) != -1) { switch (opt) { case 'd': isDaemon = true; indexFilePath = 2; break; - + case 'h': + showHelp(); + return 0; default: - usage(); + showInvalidUsage(); return -1; } } @@ -190,7 +207,7 @@ int main(int argc, char *argv[]) // Check the number of arguments if ((argc < indexFilePath + 1) || (argc > indexFilePath + 2)) { - usage(); + showInvalidUsage(); return -1; } -- cgit v1.1