+bool Application::processCommandLine(int argc, char ** argv)
+{
+ Common::iLogger::Severity consoleSeverityLevel = Common::iLogger::Fatal;
+
+ QStringList args;
+ for (int i = 1; i < argc; ++i)
+ args += argv[i];
+
+ for (int i = 0; i < args.size(); ++i) {
+ // Get the argument and optional value
+ QStringList arg = args.at(i).simplified().split(QChar('='));
+
+ if (QRegExp("(-[-]?version)|([-//]V)").exactMatch(arg.at(0))) {
+ printVersion();
+ return false;
+ }
+ else if (QRegExp("(-[-]?help)|([-//][h/?])").exactMatch(arg.at(0))) {
+ printHelp();
+ return false;
+ }
+ else if (QRegExp("-[-]?verbose").exactMatch(arg.at(0)) && arg.size() > 1) {
+ QString v = arg.at(1).toLower();
+ if (v == "debug")
+ consoleSeverityLevel = Common::iLogger::Debug;
+ else if (v == "info")
+ consoleSeverityLevel = Common::iLogger::Info;
+ else if (v == "warning")
+ consoleSeverityLevel = Common::iLogger::Warning;
+ else if (v == "error")
+ consoleSeverityLevel = Common::iLogger::Error;
+ else if (v == "fatal")
+ consoleSeverityLevel = Common::iLogger::Fatal;
+ else if (v == "none") {
+ consoleSeverityLevel = Common::iLogger::None;
+ }
+ else {
+ printHelp();
+ return false;
+ }
+ }
+ else if (QRegExp("-[v]+").exactMatch(arg.at(0)) && arg.size() == 1) {
+ // The number of 'v's increases the verbosity
+ for (int j = 1; j < arg.at(0).size(); ++j) {
+ switch (consoleSeverityLevel) {
+ case Common::iLogger::None:
+ consoleSeverityLevel = Common::iLogger::Fatal;
+ break;
+ case Common::iLogger::Fatal:
+ consoleSeverityLevel = Common::iLogger::Error;
+ break;
+ case Common::iLogger::Error:
+ consoleSeverityLevel = Common::iLogger::Warning;
+ break;
+ case Common::iLogger::Warning:
+ consoleSeverityLevel = Common::iLogger::Info;
+ break;
+ case Common::iLogger::Info:
+ consoleSeverityLevel = Common::iLogger::Debug;
+ break;
+ default:
+ break;
+ }
+ }
+ }
+ }
+
+ // Set the console severity
+ Common::iLogger::instance()->setConsoleSeverity(consoleSeverityLevel);
+
+ return true;
+}
+
+void Application::printHelp()
+{
+ char const * const txt = QT_TR_NOOP(
+ "Usage: eVafCLI [options]\n"
+ "\n"
+ // General options
+ " -help Shows this help and quits.\n"
+ " -version Shows version information and quits.\n"
+ " -verbose=LEVEL Specifies the verbose level. LEVEL can be one of the\n"
+ " following: NONE, FATAL, ERROR, WARNING, INFO, DEBUG.\n"
+ " -v Makes the application more verbose. Can be repeated for\n"
+ " more verbosity.\n"
+ // Handled by the iApp interface implementation
+ " -appl[ication]=NAME Specifies the name of the application.\n"
+ " -lang[uage]=xx[_CC] Specifies the language, where xx is the ISO 639\n"
+ " language code followed by an optional ISO 3166 country\n"
+ " code.\n"
+ " -root[dir]=DIR Specifies the application's root directory.\n"
+ " -dataroot[dir]=DIR Specifies the data root directory.\n"
+ " -etc[dir]=DIR Specifies the configuration files directory.\n"
+ " -log[dir]=DIR Specifies the log files directory.\n"
+ " -doc[dir]=DIR Specifies the documentation directory.\n"
+ " -qtplugins[dir]=DIR Specifies the Qt plugins directory.\n"
+ );
+ ::fputs(tr(txt).toLocal8Bit().constData(), stdout);
+}
+
+void Application::printVersion()
+{
+ ::printf("%s version %s release date %s, %s version %s\n",
+ VER_PRODUCT_NAME_STR,
+ VER_PRODUCT_VERSION_STR,
+ VER_PRODUCT_DATE_STR,
+ VER_MODULE_NAME_STR,
+ VER_FILE_VERSION_STR
+ );
+}
+