Skip to content

Commit

Permalink
move $NO_COLOR check to main()
Browse files Browse the repository at this point in the history
  • Loading branch information
Toni500github committed Apr 16, 2024
1 parent f378da7 commit c063e56
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
3 changes: 0 additions & 3 deletions include/fmt/color.h
Original file line number Diff line number Diff line change
Expand Up @@ -446,9 +446,6 @@ template <typename Char>
void vformat_to(
buffer<Char>& buf, const text_style& ts, basic_string_view<Char> format_str,
basic_format_args<buffered_context<type_identity_t<Char>>> args) {
char *no_color = getenv("NO_COLOR");
if (no_color != NULL && no_color[0] != '\0')
disable_colors = true;

if (disable_colors) {
detail::vformat_to(buf, format_str, args, {});
Expand Down
8 changes: 6 additions & 2 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -403,7 +403,8 @@ int parseargs(int argc, char* argv[]) {
// main
int main(int argc, char* argv[]) {
config = std::make_unique<Config>();

char *no_color = getenv("NO_COLOR");

configfile = (getConfigDir() + "/config.toml");
themefile = (getConfigDir() + "/theme.toml");

Expand All @@ -414,7 +415,10 @@ int main(int argc, char* argv[]) {
// i just want to feel good about having this check
config->init(configfile, themefile);

fmt::disable_colors = config->colors == 0;
fmt::disable_colors = config->colors == false;
if (no_color != NULL && no_color[0] != '\0')
fmt::disable_colors = true;


if(op.test_colors) {
test_colors();
Expand Down

0 comments on commit c063e56

Please sign in to comment.