From f3654aa22bf849d0f0563fd27d55e36fb95bf5f3 Mon Sep 17 00:00:00 2001 From: djcb Date: Sun, 23 Dec 2012 00:04:09 +0200 Subject: [PATCH] * paper over the missing options bug (WIP) --- mu/mu-cmd-find.c | 2 +- mu/mu-config.c | 12 ++++++++---- mu/mu-config.h | 2 +- mu/mu.cc | 17 ++++++++++------- 4 files changed, 20 insertions(+), 13 deletions(-) diff --git a/mu/mu-cmd-find.c b/mu/mu-cmd-find.c index 455ddd76..0435627d 100644 --- a/mu/mu-cmd-find.c +++ b/mu/mu-cmd-find.c @@ -127,7 +127,7 @@ run_query (MuQuery *xapian, const gchar *query, MuConfig *opts, GError **err) qflags |= MU_QUERY_FLAG_THREADS; if (opts->reverse) qflags |= MU_QUERY_FLAG_DESCENDING; - if (opts->no_dups) + if (opts->skip_dups) qflags |= MU_QUERY_FLAG_SKIP_DUPS; iter = mu_query_run (xapian, query, sortid, -1, qflags, err); diff --git a/mu/mu-config.c b/mu/mu-config.c index 1d290fd5..c67fb8d7 100644 --- a/mu/mu-config.c +++ b/mu/mu-config.c @@ -213,8 +213,8 @@ config_options_group_find (void) "use a bookmarked query", ""}, {"reverse", 'z', 0, G_OPTION_ARG_NONE, &MU_CONFIG.reverse, "sort in reverse (descending) order (z -> a)", NULL}, - {"no-dups", 'u', 0, G_OPTION_ARG_NONE, - &MU_CONFIG.no_dups, + {"skip-dups", 'u', 0, G_OPTION_ARG_NONE, + &MU_CONFIG.skip_dups, "show only the first of messages duplicates (false)", NULL}, {"linksdir", 0, 0, G_OPTION_ARG_STRING, &MU_CONFIG.linksdir, "output as symbolic links to a target maildir", ""}, @@ -596,7 +596,7 @@ mu_config_show_help (MuConfigCmd cmd) g_return_if_fail (mu_config_cmd_is_valid(cmd)); - ctx = g_option_context_new (""); + ctx = g_option_context_new ("- mu help"); g_option_context_set_main_group (ctx, config_options_group_mu()); group = get_option_group (cmd); @@ -654,6 +654,7 @@ parse_params (int *argcp, char ***argvp, GError **err) gboolean rv; context = g_option_context_new("- mu general options"); + g_option_context_set_help_enabled (context, TRUE); err = NULL; @@ -663,7 +664,9 @@ parse_params (int *argcp, char ***argvp, GError **err) config_options_group_mu()); switch (MU_CONFIG.cmd) { - case MU_CONFIG_CMD_NONE: show_usage(); break; + case MU_CONFIG_CMD_NONE: + show_usage(); + break; case MU_CONFIG_CMD_HELP: /* 'help' is special; sucks in the options of the * command after it */ @@ -675,6 +678,7 @@ parse_params (int *argcp, char ***argvp, GError **err) if (group) g_option_context_add_group(context, group); rv = g_option_context_parse (context, argcp, argvp, err); + break; } g_option_context_free (context); diff --git a/mu/mu-config.h b/mu/mu-config.h index 399bcd39..c7c25a71 100644 --- a/mu/mu-config.h +++ b/mu/mu-config.h @@ -139,7 +139,7 @@ struct _MuConfig { gchar *exec; /* command to execute on the * files for the matched * messages */ - gboolean no_dups; /* if there are multiple + gboolean skip_dups; /* if there are multiple * messages with the same * msgid, show only the first * one */ diff --git a/mu/mu.cc b/mu/mu.cc index c37c5e7c..5aeda100 100644 --- a/mu/mu.cc +++ b/mu/mu.cc @@ -49,12 +49,15 @@ show_version (void) static void -handle_error (MuConfig *conf, GError *err) +handle_error (MuConfig *conf, MuError merr, GError **err) { - if (!err) - return; /* nothing to do */ + if (merr != MU_OK && !(err && *err)) { + g_printerr ("mu: something went wrong\n"); + return; + } else if (!(err && *err)) + return; - switch (err->code) { + switch ((*err)->code) { case MU_ERROR_XAPIAN_CANNOT_GET_WRITELOCK: g_printerr ("maybe mu is already running?\n"); break; @@ -74,8 +77,8 @@ handle_error (MuConfig *conf, GError *err) break; /* nothing to do */ } - if (err) - g_printerr ("mu: %s\n", err->message); + if (*err) + g_printerr ("mu: %s\n", (*err)->message); } @@ -113,7 +116,7 @@ main (int argc, char *argv[]) rv = mu_cmd_execute (conf, &err); cleanup: - handle_error (conf, err); + handle_error (conf, rv, &err); g_clear_error (&err); mu_config_uninit (conf);