mirror of
https://gitlab.kitware.com/cmake/cmake.git
synced 2026-09-25 04:09:36 +03:00
Diagnostics: Use command-line option forms in messages
Tweak how we include the diagnostic category name in diagnostic messages to use the 'command-line option form' (i.e. lower case with hyphens) rather than the 'identifier form' (upper case with underscores). This looks nicer, as it avoids unnecessary 'shouting'.
This commit is contained in:
+10
-4
@@ -2,11 +2,10 @@
|
||||
file LICENSE.rst or https://cmake.org/licensing for details. */
|
||||
#include "cmMessenger.h"
|
||||
|
||||
#include <algorithm>
|
||||
#include <sstream>
|
||||
#include <utility>
|
||||
|
||||
#include <cm/string_view>
|
||||
|
||||
#include "cmDocumentationFormatter.h"
|
||||
#include "cmMessageMetadata.h"
|
||||
#include "cmMessageType.h"
|
||||
@@ -49,6 +48,14 @@ char const* getMessageTypeStr(MessageType t)
|
||||
return "Warning";
|
||||
}
|
||||
|
||||
std::string getDiagnosticCategoryStr(cmDiagnosticCategory category)
|
||||
{
|
||||
std::string out = cmSystemTools::LowerCase(
|
||||
cmDiagnostics::GetCategoryString(category).substr(4));
|
||||
std::replace(out.begin(), out.end(), '_', '-');
|
||||
return out;
|
||||
}
|
||||
|
||||
cm::StdIo::TermAttr getMessageColor(MessageType t)
|
||||
{
|
||||
switch (t) {
|
||||
@@ -250,8 +257,7 @@ void cmMessenger::DisplayMessage(MessageType type,
|
||||
// Print the message preamble.
|
||||
msg << "CMake " << getMessageTypeStr(type);
|
||||
if (category != cmDiagnostics::CMD_NONE) {
|
||||
cm::string_view const cname = cmDiagnostics::GetCategoryString(category);
|
||||
msg << " (" << cname.substr(4) << ')';
|
||||
msg << " (" << getDiagnosticCategoryStr(category) << ')';
|
||||
}
|
||||
|
||||
// Add the immediate context.
|
||||
|
||||
Reference in New Issue
Block a user