* mu-cmd-find.c: refactor a bit so we pass line33

This commit is contained in:
Dirk-Jan C. Binnema 2011-01-09 15:12:27 +02:00
parent f42f0cdf8f
commit f1cedf7341
1 changed files with 23 additions and 15 deletions

View File

@ -187,17 +187,11 @@ run_query (MuQuery *xapian, const gchar *query, MuConfig *opts,
}
static gboolean
query_params_valid (MuConfig *opts)
format_params_valid (MuConfig *opts)
{
OutputFormat format;
const gchar *xpath;
if (opts->linksdir)
if (opts->xquery) {
g_warning ("invalid option for --linksdir");
return FALSE;
}
format = get_output_format (opts->formatstr);
if (format == FORMAT_NONE) {
@ -206,11 +200,6 @@ query_params_valid (MuConfig *opts)
return FALSE;
}
if (opts->xquery) {
g_warning ("--xquery is obsolete; use --format=xquery instead");
return FALSE;
}
if (format == FORMAT_LINKS && !opts->linksdir) {
g_warning ("missing --linksdir argument");
return FALSE;
@ -221,6 +210,25 @@ query_params_valid (MuConfig *opts)
return FALSE;
}
return TRUE;
}
static gboolean
query_params_valid (MuConfig *opts)
{
const gchar *xpath;
if (opts->linksdir)
if (opts->xquery) {
g_warning ("invalid option for --linksdir");
return FALSE;
}
if (opts->xquery) {
g_warning ("--xquery is obsolete; use --format=xquery instead");
return FALSE;
}
xpath = mu_runtime_xapian_dir();
if (mu_util_check_dir (xpath, TRUE, FALSE))
@ -343,7 +351,7 @@ mu_cmd_find (MuConfig *opts)
g_return_val_if_fail (opts, FALSE);
g_return_val_if_fail (opts->cmd == MU_CONFIG_CMD_FIND, FALSE);
if (!query_params_valid (opts))
if (!query_params_valid (opts) || !format_params_valid(opts))
return MU_EXITCODE_ERROR;
format = get_output_format (opts->formatstr);