* revert "removed 'nocolor' option. Added 'color' option that takes (auto|never|always) instead."

(broke unit tests)

This reverts commit a4c07c9b90.

Conflicts:
	mu/mu-config.c
This commit is contained in:
djcb
2014-02-15 12:09:07 +02:00
parent 60e863b562
commit 3f6b3df477
2 changed files with 10 additions and 20 deletions

View File

@ -76,23 +76,14 @@ set_group_mu_defaults (void)
g_free(MU_CONFIG.muhome); g_free(MU_CONFIG.muhome);
MU_CONFIG.muhome = exp; MU_CONFIG.muhome = exp;
} }
}
static gboolean /* check for the MU_NOCOLOR env var; but in any case don't
config_options_set_color (const gchar *option_name, * use colors unless we're writing to a tty */
const gchar *value, if (g_getenv (MU_NOCOLOR) != NULL)
gpointer data, MU_CONFIG.nocolor = TRUE;
GError **error)
{ if (!isatty(fileno(stdout)) || !isatty(fileno(stderr)))
if( g_strcmp0( value, "never") == 0)
MU_CONFIG.nocolor = TRUE; 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* static GOptionGroup*
@ -110,9 +101,8 @@ config_options_group_mu (void)
"specify an alternative mu directory", "<dir>"}, "specify an alternative mu directory", "<dir>"},
{"log-stderr", 0, 0, G_OPTION_ARG_NONE, &MU_CONFIG.log_stderr, {"log-stderr", 0, 0, G_OPTION_ARG_NONE, &MU_CONFIG.log_stderr,
"log to standard error (false)", NULL}, "log to standard error (false)", NULL},
{"color", 0, 0, G_OPTION_ARG_CALLBACK, {"nocolor", 0, 0, G_OPTION_ARG_NONE, &MU_CONFIG.nocolor,
(gpointer)&config_options_set_color, "don't use ANSI-colors in output (false)", NULL},
"colorize output (never|auto|always)", "<mode>"},
{"verbose", 'v', 0, G_OPTION_ARG_NONE, &MU_CONFIG.verbose, {"verbose", 'v', 0, G_OPTION_ARG_NONE, &MU_CONFIG.verbose,
"verbose output (false)", NULL}, "verbose output (false)", NULL},