* cfind: add support for the --after and --personal parameters, and document them

This commit is contained in:
djcb 2012-06-20 09:20:15 +03:00
parent b150f45090
commit 2c99e598a1
4 changed files with 50 additions and 9 deletions

View File

@ -1,4 +1,4 @@
.TH MU CFIND 1 "May 2011" "User Manuals"
.TH MU CFIND 1 "June 2012" "User Manuals"
.SH NAME
@ -61,6 +61,24 @@ sets the output format to the given value. The following are available:
| csv | comma-separated values |
.fi
.TP
\fB\-\-personal\fR only show addresses seen in messages where one of 'my'
e-mail addresses was seen in one of the address fields; this is to exclude
addresses only seen in mailing-list messages. See the \fB\-\-my-address\fR
parameter in \fBmu index\fR.
.TP
\fB\-\-after=\fR\fI<timestamp>\fR only show addresses last seen after
\fI<timestamp>\fR. \fI<timestamp>\fR is a UNIX \fBtime_t\fR value, the number
of seconds since 1970-01-01 (in UTC).
From the command line, you can use the \fBdate\fR command to get this
value. For example, only consider addresses last seen after 2009-06-01, you
could specify
.nf
--after=`date +%s --date='2009-06-01'`
.fi
.SH RETURN VALUE
\fBmu cfind\fR returns 0 upon successful completion -- that is, at least one

View File

@ -130,7 +130,8 @@ print_plain (const char *email, const char *name, gboolean color)
struct _ECData {
MuConfigFormat format;
gboolean color;
gboolean color, personal;
time_t after;
};
typedef struct _ECData ECData;
@ -139,6 +140,12 @@ static void
each_contact (const char *email, const char *name, gboolean personal,
time_t tstamp, ECData *ecdata)
{
if (ecdata->personal && !personal)
return;
if (ecdata->after < tstamp)
return;
switch (ecdata->format) {
case MU_CONFIG_FORMAT_MUTT_ALIAS:
each_contact_mutt_alias (email, name);
@ -166,7 +173,9 @@ each_contact (const char *email, const char *name, gboolean personal,
static MuError
run_cmd_cfind (const char* pattern, MuConfigFormat format,
run_cmd_cfind (const char* pattern,
gboolean personal, time_t after,
MuConfigFormat format,
gboolean color, GError **err)
{
gboolean rv;
@ -174,8 +183,10 @@ run_cmd_cfind (const char* pattern, MuConfigFormat format,
size_t num;
ECData ecdata;
ecdata.format = format;
ecdata.color = color;
ecdata.personal = personal;
ecdata.after = after;
ecdata.format = format;
ecdata.color = color;
contacts = mu_contacts_new (mu_runtime_path(MU_RUNTIME_PATH_CONTACTS));
if (!contacts) {
@ -239,6 +250,10 @@ mu_cmd_cfind (MuConfig *opts, GError **err)
return MU_ERROR_IN_PARAMETERS;
}
return run_cmd_cfind (opts->params[1], opts->format,
!opts->nocolor, err);
return run_cmd_cfind (opts->params[1],
opts->personal,
opts->after,
opts->format,
!opts->nocolor,
err);
}

View File

@ -151,8 +151,7 @@ config_options_group_index (void)
{"my-address", 0, 0, G_OPTION_ARG_STRING_ARRAY,&MU_CONFIG.my_addresses,
"my e-mail address (regexp); can be used multiple times", NULL},
{"autoupgrade", 0, 0, G_OPTION_ARG_NONE, &MU_CONFIG.autoupgrade,
"auto-upgrade the database with new mu versions (false)",
NULL},
"auto-upgrade the database with new mu versions (false)", NULL},
{"nocleanup", 0, 0, G_OPTION_ARG_NONE, &MU_CONFIG.nocleanup,
"don't clean up the database after indexing (false)", NULL},
{"xbatchsize", 0, 0, G_OPTION_ARG_INT, &MU_CONFIG.xbatchsize,
@ -273,6 +272,7 @@ set_group_cfind_defaults (void)
else
MU_CONFIG.format = get_output_format (MU_CONFIG.formatstr);
MU_CONFIG.after = 0;
}
@ -284,6 +284,10 @@ config_options_group_cfind (void)
{"format", 'o', 0, G_OPTION_ARG_STRING, &MU_CONFIG.formatstr,
"output format ('plain'(*), 'mutt', 'wanderlust',"
"'org-contact', 'csv')", NULL},
{"personal", 0, 0, G_OPTION_ARG_NONE, &MU_CONFIG.personal,
"whether to only get 'personal' contacts", NULL},
{"after", 0, 0, G_OPTION_ARG_INT, &MU_CONFIG.after,
"only get addresses last seen after T", NULL},
{NULL, 0, 0, 0, NULL, NULL, NULL}
};

View File

@ -136,6 +136,10 @@ struct _MuConfig {
gboolean terminator; /* add separator \f between
* multiple messages in mu
* view */
/* options for cfind */
gboolean personal; /* only show 'personal' addresses */b
time_t after; /* only show addresses last
* seen after T */
/* output to a maildir with symlinks */
char *linksdir; /* maildir to output symlinks */