From 3f6b3df477f9e9a593f4a41c84a81f69f2fe1ed0 Mon Sep 17 00:00:00 2001 From: djcb Date: Sat, 15 Feb 2014 12:09:07 +0200 Subject: [PATCH] * revert "removed 'nocolor' option. Added 'color' option that takes (auto|never|always) instead." (broke unit tests) This reverts commit a4c07c9b90007bbacd2362d0ff2b145907761fbe. Conflicts: mu/mu-config.c --- mu/mu-config.c | 26 ++++++++------------------ mu/mu-config.h | 4 ++-- 2 files changed, 10 insertions(+), 20 deletions(-) diff --git a/mu/mu-config.c b/mu/mu-config.c index 21848969..5af1ccb7 100644 --- a/mu/mu-config.c +++ b/mu/mu-config.c @@ -76,23 +76,14 @@ set_group_mu_defaults (void) g_free(MU_CONFIG.muhome); MU_CONFIG.muhome = exp; } -} -static gboolean -config_options_set_color (const gchar *option_name, - const gchar *value, - gpointer data, - GError **error) -{ - if( g_strcmp0( value, "never") == 0) + /* check for the MU_NOCOLOR env var; but in any case don't + * use colors unless we're writing to a tty */ + if (g_getenv (MU_NOCOLOR) != NULL) + MU_CONFIG.nocolor = TRUE; + + if (!isatty(fileno(stdout)) || !isatty(fileno(stderr))) MU_CONFIG.nocolor = TRUE; - else if( g_strcmp0( value, "auto") == 0) - MU_CONFIG.nocolor = (!isatty(fileno(stdout)) || !isatty(fileno(stderr))); - else if( g_strcmp0( value, "always") == 0) - MU_CONFIG.nocolor = FALSE; - else - return FALSE; - return TRUE; } static GOptionGroup* @@ -110,9 +101,8 @@ config_options_group_mu (void) "specify an alternative mu directory", ""}, {"log-stderr", 0, 0, G_OPTION_ARG_NONE, &MU_CONFIG.log_stderr, "log to standard error (false)", NULL}, - {"color", 0, 0, G_OPTION_ARG_CALLBACK, - (gpointer)&config_options_set_color, - "colorize output (never|auto|always)", ""}, + {"nocolor", 0, 0, G_OPTION_ARG_NONE, &MU_CONFIG.nocolor, + "don't use ANSI-colors in output (false)", NULL}, {"verbose", 'v', 0, G_OPTION_ARG_NONE, &MU_CONFIG.verbose, "verbose output (false)", NULL}, diff --git a/mu/mu-config.h b/mu/mu-config.h index f14ad73a..a45072a5 100644 --- a/mu/mu-config.h +++ b/mu/mu-config.h @@ -102,8 +102,8 @@ struct _MuConfig { gboolean version; /* request mu version */ gboolean log_stderr; /* log to stderr (not logfile) */ gchar** params; /* parameters (for querying) */ - gboolean nocolor; /* don't use use ansi-colors - * in some output */ + gboolean nocolor; /* don't use use ansi-colors + * in some output */ gboolean verbose; /* verbose output */ /* options for indexing */