mirror of https://github.com/djcb/mu.git
* mu-config: add the --color option, to enable color output in some cases (or, alternatively, set the MU_COLOR env var to non-empty)
This commit is contained in:
parent
bc8c1a0289
commit
2b56e46260
|
@ -1,5 +1,4 @@
|
||||||
/* -*-mode: c; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-*/
|
/* -*-mode: c; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
** Copyright (C) 2008-2011 Dirk-Jan C. Binnema <djcb@djcbsoftware.nl>
|
** Copyright (C) 2008-2011 Dirk-Jan C. Binnema <djcb@djcbsoftware.nl>
|
||||||
**
|
**
|
||||||
|
@ -43,6 +42,9 @@ set_group_mu_defaults (MuConfig *opts)
|
||||||
g_free(opts->muhome);
|
g_free(opts->muhome);
|
||||||
opts->muhome = exp;
|
opts->muhome = exp;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (g_getenv (MU_COLORS) != NULL)
|
||||||
|
opts->color = TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static GOptionGroup*
|
static GOptionGroup*
|
||||||
|
@ -60,6 +62,9 @@ config_options_group_mu (MuConfig *opts)
|
||||||
"specify an alternative mu directory", NULL},
|
"specify an alternative mu directory", NULL},
|
||||||
{"log-stderr", 0, 0, G_OPTION_ARG_NONE, &opts->log_stderr,
|
{"log-stderr", 0, 0, G_OPTION_ARG_NONE, &opts->log_stderr,
|
||||||
"log to standard error (false)", NULL},
|
"log to standard error (false)", NULL},
|
||||||
|
{"color", 0, 0, G_OPTION_ARG_NONE, &opts->color,
|
||||||
|
"use ANSI-colors in some output (false)", NULL},
|
||||||
|
|
||||||
{G_OPTION_REMAINING, 0, 0, G_OPTION_ARG_STRING_ARRAY,
|
{G_OPTION_REMAINING, 0, 0, G_OPTION_ARG_STRING_ARRAY,
|
||||||
&opts->params, "parameters", NULL},
|
&opts->params, "parameters", NULL},
|
||||||
{NULL, 0, 0, 0, NULL, NULL, NULL}
|
{NULL, 0, 0, 0, NULL, NULL, NULL}
|
||||||
|
@ -136,11 +141,6 @@ set_group_find_defaults (MuConfig *opts)
|
||||||
else
|
else
|
||||||
g_free(old);
|
g_free(old);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* FIXME: some warning when summary_len < 0? */
|
|
||||||
if (opts->summary_len < 1)
|
|
||||||
opts->summary_len = 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static GOptionGroup*
|
static GOptionGroup*
|
||||||
|
@ -156,8 +156,8 @@ config_options_group_find (MuConfig *opts)
|
||||||
"use a bookmarked query", NULL},
|
"use a bookmarked query", NULL},
|
||||||
{"descending", 'z', 0, G_OPTION_ARG_NONE, &opts->descending,
|
{"descending", 'z', 0, G_OPTION_ARG_NONE, &opts->descending,
|
||||||
"sort in descending order (z -> a)", NULL},
|
"sort in descending order (z -> a)", NULL},
|
||||||
{"summary-len", 'k', 0, G_OPTION_ARG_INT, &opts->summary_len,
|
{"summary", 'k', 0, G_OPTION_ARG_NONE, &opts->summary,
|
||||||
"max number of lines for summary (0)", NULL},
|
"include a short summary of the message (false)", NULL},
|
||||||
{"linksdir", 0, 0, G_OPTION_ARG_STRING, &opts->linksdir,
|
{"linksdir", 0, 0, G_OPTION_ARG_STRING, &opts->linksdir,
|
||||||
"output as symbolic links to a target maildir", NULL},
|
"output as symbolic links to a target maildir", NULL},
|
||||||
{"clearlinks", 0, 0, G_OPTION_ARG_NONE, &opts->clearlinks,
|
{"clearlinks", 0, 0, G_OPTION_ARG_NONE, &opts->clearlinks,
|
||||||
|
@ -224,9 +224,27 @@ config_options_group_cfind (MuConfig *opts)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static GOptionGroup *
|
||||||
|
config_options_group_view (MuConfig *opts)
|
||||||
|
{
|
||||||
|
GOptionGroup *og;
|
||||||
|
GOptionEntry entries[] = {
|
||||||
|
{"summary", 0, 0, G_OPTION_ARG_NONE, &opts->summary,
|
||||||
|
"only show a short summary of the message (false)", NULL},
|
||||||
|
{NULL, 0, 0, 0, NULL, NULL, NULL}
|
||||||
|
};
|
||||||
|
|
||||||
|
og = g_option_group_new("cfind", "options for the 'cfind' command",
|
||||||
|
"", NULL, NULL);
|
||||||
|
g_option_group_add_entries(og, entries);
|
||||||
|
|
||||||
|
return og;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
static GOptionGroup*
|
static GOptionGroup*
|
||||||
config_options_group_extract(MuConfig *opts)
|
config_options_group_extract (MuConfig *opts)
|
||||||
{
|
{
|
||||||
GOptionGroup *og;
|
GOptionGroup *og;
|
||||||
GOptionEntry entries[] = {
|
GOptionEntry entries[] = {
|
||||||
|
@ -321,6 +339,9 @@ add_context_group (GOptionContext *context, MuConfig *opts)
|
||||||
case MU_CONFIG_CMD_CFIND:
|
case MU_CONFIG_CMD_CFIND:
|
||||||
group = config_options_group_cfind (opts);
|
group = config_options_group_cfind (opts);
|
||||||
break;
|
break;
|
||||||
|
case MU_CONFIG_CMD_VIEW:
|
||||||
|
group = config_options_group_view (opts);
|
||||||
|
break;
|
||||||
default: break;
|
default: break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -29,6 +29,9 @@
|
||||||
|
|
||||||
G_BEGIN_DECLS
|
G_BEGIN_DECLS
|
||||||
|
|
||||||
|
/* env var; if non-empty, color are enabled for some commands */
|
||||||
|
#define MU_COLORS "MU_COLORS"
|
||||||
|
|
||||||
/* output formats for 'mu find' */
|
/* output formats for 'mu find' */
|
||||||
#define MU_CONFIG_FORMAT_PLAIN "plain" /* plain text output */
|
#define MU_CONFIG_FORMAT_PLAIN "plain" /* plain text output */
|
||||||
#define MU_CONFIG_FORMAT_LINKS "links" /* output as symlinks */
|
#define MU_CONFIG_FORMAT_LINKS "links" /* output as symlinks */
|
||||||
|
@ -77,6 +80,7 @@ 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 color; /* use ansi-colors in some output */
|
||||||
|
|
||||||
/* options for indexing */
|
/* options for indexing */
|
||||||
char *maildir; /* where the mails are */
|
char *maildir; /* where the mails are */
|
||||||
|
@ -90,11 +94,11 @@ struct _MuConfig {
|
||||||
* default */
|
* default */
|
||||||
int max_msg_size; /* maximum size for message files */
|
int max_msg_size; /* maximum size for message files */
|
||||||
|
|
||||||
/* options for querying */
|
/* options for querying (and view-> 'summary') */
|
||||||
char *fields; /* fields to show in output */
|
char *fields; /* fields to show in output */
|
||||||
char *sortfield; /* field to sort by (string) */
|
char *sortfield; /* field to sort by (string) */
|
||||||
gboolean descending; /* sort descending? */
|
gboolean descending; /* sort descending? */
|
||||||
unsigned summary_len; /* max # of lines of msg in summary */
|
gboolean summary; /* include a summary? */
|
||||||
char *bookmark; /* use bookmark */
|
char *bookmark; /* use bookmark */
|
||||||
char *formatstr; /* output type
|
char *formatstr; /* output type
|
||||||
* (plain,links,xml,json,sexp) */
|
* (plain,links,xml,json,sexp) */
|
||||||
|
|
Loading…
Reference in New Issue