Merge pull request #277 from tmalsburg/master

* added maxnum argument to mu find
This commit is contained in:
Dirk-Jan C. Binnema 2013-09-28 10:48:04 -07:00
commit 4bdd64492a
4 changed files with 13 additions and 2 deletions

View File

@ -1,4 +1,4 @@
.TH MU FIND 1 "June 2013" "User Manuals"
.TH MU FIND 1 "September 2013" "User Manuals"
.SH NAME
@ -343,6 +343,10 @@ Note, if you specify a sortfield, by default, messages are sorted in reverse
(descending) order (e.g., from lowest to highest). This is usually a good
choice, but for dates it may be more useful to sort in the opposite direction.
.TP
\fB\-n\fR, \fB\-\-maxnum=<number>\fR
If > 0, display maximally that number of entries. If not specified, all matching entries are displayed.
.TP
\fB\-\-summary-len=<number>\fR
If > 0, use that number of lines of the message to provide a summary.

View File

@ -132,7 +132,7 @@ run_query (MuQuery *xapian, const gchar *query, MuConfig *opts, GError **err)
if (opts->threads)
qflags |= MU_QUERY_FLAG_THREADS;
iter = mu_query_run (xapian, query, sortid, -1, qflags, err);
iter = mu_query_run (xapian, query, sortid, opts->maxnum, qflags, err);
return iter;
}
@ -598,6 +598,8 @@ output_query_results (MuMsgIter *iter, MuConfig *opts, GError **err)
MuMsg *msg;
if (count == opts->maxnum)
break;
msg = get_message (iter, opts->after);
if (!msg)
break;

View File

@ -205,6 +205,8 @@ config_options_group_find (void)
{"sortfield", 's', 0, G_OPTION_ARG_STRING,
&MU_CONFIG.sortfield,
"field to sort on", "<field>"},
{"maxnum", 'n', 0, G_OPTION_ARG_INT, &MU_CONFIG.maxnum,
"number of entries to display in the output", "<number>"},
{"threads", 't', 0, G_OPTION_ARG_NONE, &MU_CONFIG.threads,
"show message threads", NULL},
{"bookmark", 'b', 0, G_OPTION_ARG_STRING, &MU_CONFIG.bookmark,
@ -702,6 +704,8 @@ mu_config_init (int *argcp, char ***argvp, GError **err)
memset (&MU_CONFIG, 0, sizeof(MU_CONFIG));
MU_CONFIG.maxnum = -1; /* By default, output all matching entries. */
if (!parse_cmd (argcp, argvp, err))
goto errexit;

View File

@ -123,6 +123,7 @@ struct _MuConfig {
/* options for querying 'find' (and view-> 'summary') */
gchar *fields; /* fields to show in output */
gchar *sortfield; /* field to sort by (string) */
int maxnum; /* max # of entries to print */
gboolean reverse; /* sort in revers order (z->a) */
gboolean threads; /* show message threads */