| 606 | } |
| 607 | |
| 608 | static void replaceColors(std::string& source, bool erase) { |
| 609 | // TODO: colors are not applied when either stdout or stderr is not a TTY because we resolve them before the stream usage |
| 610 | static const std::unordered_map<std::string, std::string> substitutionMapReplace = |
| 611 | { |
| 612 | {"{reset}", ::toString(Color::Reset)}, |
| 613 | {"{bold}", ::toString(Color::Bold)}, |
| 614 | {"{dim}", ::toString(Color::Dim)}, |
| 615 | {"{red}", ::toString(Color::FgRed)}, |
| 616 | {"{green}", ::toString(Color::FgGreen)}, |
| 617 | {"{blue}", ::toString(Color::FgBlue)}, |
| 618 | {"{magenta}", ::toString(Color::FgMagenta)}, |
| 619 | {"{default}", ::toString(Color::FgDefault)}, |
| 620 | }; |
| 621 | static const std::unordered_map<std::string, std::string> substitutionMapErase = |
| 622 | { |
| 623 | {"{reset}", ""}, |
| 624 | {"{bold}", ""}, |
| 625 | {"{dim}", ""}, |
| 626 | {"{red}", ""}, |
| 627 | {"{green}", ""}, |
| 628 | {"{blue}", ""}, |
| 629 | {"{magenta}", ""}, |
| 630 | {"{default}", ""}, |
| 631 | }; |
| 632 | if (!erase) |
| 633 | replace(source, substitutionMapReplace); |
| 634 | else |
| 635 | replace(source, substitutionMapErase); |
| 636 | } |
| 637 | |
| 638 | std::string ErrorMessage::toString(bool verbose, const std::string &templateFormat, const std::string &templateLocation) const |
| 639 | { |
no test coverage detected