mirror of https://github.com/djcb/mu.git
removed 'nocolor' option. Added 'color' option that takes (auto|never|always) instead.
This commit is contained in:
parent
599d641034
commit
a4c07c9b90
|
@ -79,11 +79,28 @@ set_group_mu_defaults (void)
|
||||||
|
|
||||||
/* check for the MU_NOCOLOR env var; but in any case don't
|
/* check for the MU_NOCOLOR env var; but in any case don't
|
||||||
* use colors unless we're writing to a tty */
|
* 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)))
|
if( MU_CONFIG.color == MuColorOpt_always)
|
||||||
|
MU_CONFIG.nocolor= FALSE;
|
||||||
|
else if( MU_CONFIG.color == MuColorOpt_never)
|
||||||
MU_CONFIG.nocolor = TRUE;
|
MU_CONFIG.nocolor = TRUE;
|
||||||
|
else if (!isatty(fileno(stdout)) || !isatty(fileno(stderr)))
|
||||||
|
MU_CONFIG.nocolor = TRUE;
|
||||||
|
else if (g_getenv (MU_NOCOLOR) != NULL)
|
||||||
|
MU_CONFIG.nocolor = TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
static gboolean config_options_set_color (const gchar *option_name, const gchar *value, gpointer data, GError **error)
|
||||||
|
{
|
||||||
|
if( g_strcmp0( value, "never") == 0)
|
||||||
|
MU_CONFIG.color = MuColorOpt_never;
|
||||||
|
else if( g_strcmp0( value, "auto") == 0)
|
||||||
|
MU_CONFIG.color = MuColorOpt_auto;
|
||||||
|
else if( g_strcmp0( value, "always") == 0)
|
||||||
|
MU_CONFIG.color = MuColorOpt_always;
|
||||||
|
else
|
||||||
|
return FALSE;
|
||||||
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static GOptionGroup*
|
static GOptionGroup*
|
||||||
|
@ -101,8 +118,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},
|
||||||
{"nocolor", 0, 0, G_OPTION_ARG_NONE, &MU_CONFIG.nocolor,
|
{"color", 0, 0, G_OPTION_ARG_CALLBACK, &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},
|
||||||
|
|
||||||
|
|
|
@ -86,6 +86,12 @@ typedef enum _MuConfigCmd MuConfigCmd;
|
||||||
((C) > MU_CONFIG_CMD_UNKNOWN && (C) < MU_CONFIG_CMD_NONE)
|
((C) > MU_CONFIG_CMD_UNKNOWN && (C) < MU_CONFIG_CMD_NONE)
|
||||||
|
|
||||||
|
|
||||||
|
enum MuColorOpt {
|
||||||
|
MuColorOpt_auto,
|
||||||
|
MuColorOpt_never,
|
||||||
|
MuColorOpt_always
|
||||||
|
};
|
||||||
|
|
||||||
/* struct with all configuration options for mu; it will be filled
|
/* struct with all configuration options for mu; it will be filled
|
||||||
* from the config file, and/or command line arguments */
|
* from the config file, and/or command line arguments */
|
||||||
|
|
||||||
|
@ -102,8 +108,8 @@ struct _MuConfig {
|
||||||
gboolean version; /* request mu version */
|
gboolean version; /* request mu version */
|
||||||
gboolean log_stderr; /* log to stderr (not logfile) */
|
gboolean log_stderr; /* log to stderr (not logfile) */
|
||||||
gchar** params; /* parameters (for querying) */
|
gchar** params; /* parameters (for querying) */
|
||||||
gboolean nocolor; /* don't use use ansi-colors
|
enum MuColorOpt color; /* colorize output (enum)*/
|
||||||
* in some output */
|
gboolean nocolor; /* colorize output (boolean)*/
|
||||||
gboolean verbose; /* verbose output */
|
gboolean verbose; /* verbose output */
|
||||||
|
|
||||||
/* options for indexing */
|
/* options for indexing */
|
||||||
|
|
Loading…
Reference in New Issue