mirror of https://github.com/djcb/mu.git
* remove the '--print' option; it's implicit
This commit is contained in:
parent
b4551febd2
commit
b93402f705
|
@ -71,8 +71,6 @@ mu_config_options_group_query (MuConfigOptions *opts)
|
||||||
{
|
{
|
||||||
GOptionGroup *og;
|
GOptionGroup *og;
|
||||||
GOptionEntry entries[] = {
|
GOptionEntry entries[] = {
|
||||||
{"print", 'p', 0, G_OPTION_ARG_NONE, &opts->print,
|
|
||||||
"print matching messages to screen (default)", NULL},
|
|
||||||
{"xquery", 'x', 0, G_OPTION_ARG_NONE, &opts->xquery,
|
{"xquery", 'x', 0, G_OPTION_ARG_NONE, &opts->xquery,
|
||||||
"print a string representation of the Xapian query", NULL},
|
"print a string representation of the Xapian query", NULL},
|
||||||
{"fields", 'f', 0, G_OPTION_ARG_STRING, &opts->fields,
|
{"fields", 'f', 0, G_OPTION_ARG_STRING, &opts->fields,
|
||||||
|
@ -114,7 +112,6 @@ mu_config_set_defaults (MuConfigOptions *opts)
|
||||||
opts->reindex = FALSE;
|
opts->reindex = FALSE;
|
||||||
|
|
||||||
/* querying */
|
/* querying */
|
||||||
opts->print = TRUE;
|
|
||||||
opts->xquery = FALSE;
|
opts->xquery = FALSE;
|
||||||
opts->fields = "d f s";
|
opts->fields = "d f s";
|
||||||
}
|
}
|
||||||
|
|
|
@ -38,8 +38,8 @@ struct _MuConfigOptions {
|
||||||
gboolean reindex; /* re-index existing mails */
|
gboolean reindex; /* re-index existing mails */
|
||||||
|
|
||||||
/* options for querying */
|
/* options for querying */
|
||||||
gboolean print; /* do output */
|
gboolean xquery; /* give the Xapian query instead of
|
||||||
gboolean xquery; /* give the Xapian query (for debuging)*/
|
search results */
|
||||||
char *fields; /* fields to show in output */
|
char *fields; /* fields to show in output */
|
||||||
|
|
||||||
char* sortfield_str; /* fields to sort by */
|
char* sortfield_str; /* fields to sort by */
|
||||||
|
|
|
@ -76,7 +76,7 @@ display_field (MuMsgXapian *row, const MuMsgField* field)
|
||||||
|
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
handle_options_sort_field_dir (MuConfigOptions *opts)
|
handle_options (MuConfigOptions *opts)
|
||||||
{
|
{
|
||||||
const MuMsgField *field;
|
const MuMsgField *field;
|
||||||
|
|
||||||
|
@ -102,26 +102,6 @@ handle_options_sort_field_dir (MuConfigOptions *opts)
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
|
||||||
handle_options (MuConfigOptions *opts)
|
|
||||||
{
|
|
||||||
/* if nothing specified, or fields are specified use print */
|
|
||||||
if ((!opts->xquery)||opts->fields)
|
|
||||||
opts->print = TRUE;
|
|
||||||
|
|
||||||
/* if no fields are specified, use 'd f s' */
|
|
||||||
if (opts->print && !opts->fields) {
|
|
||||||
opts->fields = "d f s"; /* default: date-from-subject.. */
|
|
||||||
if (!opts->ascending_flag) /* ... and sort descending */
|
|
||||||
opts->sortdir_ascending = FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!handle_options_sort_field_dir (opts))
|
|
||||||
return FALSE;
|
|
||||||
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
print_rows (MuQueryXapian *xapian, const gchar *query, MuConfigOptions *opts)
|
print_rows (MuQueryXapian *xapian, const gchar *query, MuConfigOptions *opts)
|
||||||
|
@ -137,7 +117,7 @@ print_rows (MuQueryXapian *xapian, const gchar *query, MuConfigOptions *opts)
|
||||||
}
|
}
|
||||||
|
|
||||||
while (!mu_msg_xapian_is_done (row)) {
|
while (!mu_msg_xapian_is_done (row)) {
|
||||||
const char* fields = opts->fields;
|
const char* fields = opts->fields;
|
||||||
int printlen = 0;
|
int printlen = 0;
|
||||||
while (*fields) {
|
while (*fields) {
|
||||||
const MuMsgField* field =
|
const MuMsgField* field =
|
||||||
|
@ -168,13 +148,16 @@ do_output (MuQueryXapian *xapian, GSList *args, MuConfigOptions* opts)
|
||||||
gboolean retval = TRUE;
|
gboolean retval = TRUE;
|
||||||
|
|
||||||
query = mu_query_xapian_combine (args, FALSE);
|
query = mu_query_xapian_combine (args, FALSE);
|
||||||
if (opts->xquery)
|
|
||||||
|
/* if xquery is set, we print the xapian query instead of the
|
||||||
|
* output; this is for debugging purposes */
|
||||||
|
if (opts->xquery)
|
||||||
retval = print_query (xapian, query);
|
retval = print_query (xapian, query);
|
||||||
|
else
|
||||||
if (retval && opts->print)
|
|
||||||
retval = print_rows (xapian, query, opts);
|
retval = print_rows (xapian, query, opts);
|
||||||
|
|
||||||
g_free (query);
|
g_free (query);
|
||||||
|
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue