disable_colors is just a normal bool which the dev or the user can decide in the program if disable the printing of colors or not.
an example:
#include <fmt/color.h>
int main() {
// prints "Hello" in red fg
fmt::print(fg(fmt::terminal_color::red), "Hello\n");
// let's disable all colors prints
fmt::disable_colors = true;
// prints "Hello" in blank color
fmt::print(fg(fmt::terminal_color::red), "Hello\n");
}
this can be also useful in cases where the user has the enviroment variable NO_COLOR set (https://no-color.org).
another example:
#include <fmt/color.h>
int main() {
char *no_color = getenv("NO_COLOR");
// prints "Hello" in red fg
fmt::print(fg(fmt::terminal_color::red), "Hello\n");
if (no_color != NULL && no_color[0] != '\0')
fmt::disable_colors = true;
// will prints "Hello" in blank color if we have $NO_COLOR set, else it will print it in red
fmt::print(fg(fmt::terminal_color::red), "Hello\n");
}
disable_colors is just a normal bool which the dev or the user can decide in the program if disable the printing of colors or not.
an example:
this can be also useful in cases where the user has the enviroment variable
NO_COLOR
set (https://no-color.org). another example:Fixes #2137