mirror of https://github.com/djcb/mu.git
* mu-cmd-find.c: refactor a bit so we pass line33
This commit is contained in:
parent
f42f0cdf8f
commit
f1cedf7341
|
@ -187,29 +187,18 @@ run_query (MuQuery *xapian, const gchar *query, MuConfig *opts,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
query_params_valid (MuConfig *opts)
|
format_params_valid (MuConfig *opts)
|
||||||
{
|
{
|
||||||
OutputFormat format;
|
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);
|
format = get_output_format (opts->formatstr);
|
||||||
if (format == FORMAT_NONE) {
|
if (format == FORMAT_NONE) {
|
||||||
g_warning ("invalid output format %s",
|
g_warning ("invalid output format %s",
|
||||||
opts->formatstr ? opts->formatstr : "<none>");
|
opts->formatstr ? opts->formatstr : "<none>");
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (opts->xquery) {
|
|
||||||
g_warning ("--xquery is obsolete; use --format=xquery instead");
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (format == FORMAT_LINKS && !opts->linksdir) {
|
if (format == FORMAT_LINKS && !opts->linksdir) {
|
||||||
g_warning ("missing --linksdir argument");
|
g_warning ("missing --linksdir argument");
|
||||||
|
@ -220,6 +209,25 @@ query_params_valid (MuConfig *opts)
|
||||||
g_warning ("--linksdir is only valid with --format=links");
|
g_warning ("--linksdir is only valid with --format=links");
|
||||||
return FALSE;
|
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();
|
xpath = mu_runtime_xapian_dir();
|
||||||
|
|
||||||
|
@ -343,7 +351,7 @@ mu_cmd_find (MuConfig *opts)
|
||||||
g_return_val_if_fail (opts, FALSE);
|
g_return_val_if_fail (opts, FALSE);
|
||||||
g_return_val_if_fail (opts->cmd == MU_CONFIG_CMD_FIND, 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;
|
return MU_EXITCODE_ERROR;
|
||||||
|
|
||||||
format = get_output_format (opts->formatstr);
|
format = get_output_format (opts->formatstr);
|
||||||
|
|
Loading…
Reference in New Issue