refs #485, renamed to cmdLineErrorMessage (to distinguish from status messages)

This commit is contained in:
Klaus Basan
2016-03-13 18:08:38 +00:00
committed by Mathew Sutcliffe
parent 76814b43be
commit c411f07551
8 changed files with 31 additions and 29 deletions

View File

@@ -110,7 +110,7 @@ namespace BlackCore
CStatusMessage m(this->requestReloadOfSetupAndVersion());
if (m.isWarningOrAbove())
{
this->errorMessage(m.getMessage());
this->cmdLineErrorMessage(m.getMessage());
return false;
}
}
@@ -384,7 +384,7 @@ namespace BlackCore
void CApplication::severeStartupProblem(const CStatusMessage &message)
{
CLogMessage(this).preformatted(message);
this->errorMessage(message.getMessage());
this->cmdLineErrorMessage(message.getMessage());
this->exit(EXIT_FAILURE);
// if I get here the event loop was not yet running
@@ -467,7 +467,7 @@ namespace BlackCore
QStringList args(QCoreApplication::instance()->arguments());
if (!this->m_parser.parse(args))
{
this->errorMessage(this->m_parser.errorText());
this->cmdLineErrorMessage(this->m_parser.errorText());
return false;
}
@@ -475,12 +475,12 @@ namespace BlackCore
if (this->m_parser.isSet(this->m_cmdHelp))
{
// Important parser help will already stop application
this->helpMessage();
this->cmdLineHelpMessage();
return true;
}
if (this->m_parser.isSet(this->m_cmdVersion))
{
this->versionMessage();
this->cmdLineVersionMessage();
return true;
}
@@ -493,20 +493,20 @@ namespace BlackCore
return true;
}
void CApplication::errorMessage(const QString &errorMessage) const
void CApplication::cmdLineErrorMessage(const QString &errorMessage) const
{
fputs(qPrintable(errorMessage), stderr);
fputs("\n\n", stderr);
fputs(qPrintable(this->m_parser.helpText()), stderr);
}
void CApplication::helpMessage()
void CApplication::cmdLineHelpMessage()
{
this->m_parser.showHelp(); // terminates
Q_UNREACHABLE();
}
void CApplication::versionMessage() const
void CApplication::cmdLineVersionMessage() const
{
printf("%s %s\n", qPrintable(QCoreApplication::applicationName()), qPrintable(QCoreApplication::applicationVersion()));
}

View File

@@ -148,7 +148,7 @@ namespace BlackCore
QString getParserOptionValue(const QCommandLineOption &option) const;
//! Display parser error message
virtual void errorMessage(const QString &errorMessage) const;
virtual void cmdLineErrorMessage(const QString &cmdLineErrorMessage) const;
//! Parses and handles the standard options such as help, version, parse error
//! \note in some cases (error, version, help) application is terminated during this step
@@ -213,10 +213,10 @@ namespace BlackCore
CApplication(const QString &applicationName, QCoreApplication *app);
//! Display help message
virtual void helpMessage();
virtual void cmdLineHelpMessage();
//! Display version message
virtual void versionMessage() const;
virtual void cmdLineVersionMessage() const;
//! Can be used to parse specialized arguments
virtual bool parsingHookIn() { return true; }

View File

@@ -112,7 +112,7 @@ namespace BlackCore
QFile f(this->m_localSetupFileValue);
if (!f.exists())
{
sApp->errorMessage("File " + this->m_localSetupFileValue + " does not exist");
sApp->cmdLineErrorMessage("File " + this->m_localSetupFileValue + " does not exist");
return false;
}
}
@@ -124,7 +124,7 @@ namespace BlackCore
{
if (!CNetworkUtils::canConnect(url))
{
sApp->errorMessage("URL " + url.toString() + " not reachable");
sApp->cmdLineErrorMessage("URL " + url.toString() + " not reachable");
return false;
}
}