From 46a6b445b3b85b3247ec6b9c6244cf9f627f1f62 Mon Sep 17 00:00:00 2001 From: djcb Date: Tue, 12 Jun 2012 00:12:22 +0300 Subject: [PATCH] * mu: use g_print, no g_message (the latter is hidden) for output --- mu/mu-cmd-find.c | 7 +------ mu/mu-cmd-index.c | 29 +++++++++++++++-------------- mu/mu-cmd.c | 12 ++++++------ 3 files changed, 22 insertions(+), 26 deletions(-) diff --git a/mu/mu-cmd-find.c b/mu/mu-cmd-find.c index bd073ffc..d23764a2 100644 --- a/mu/mu-cmd-find.c +++ b/mu/mu-cmd-find.c @@ -850,15 +850,10 @@ execute_find (MuStore *store, MuConfig *opts, GError **err) static void show_usage (void) { - const char *usage_str = - "usage: mu find [options] \n"; - g_message ("%s", usage_str); + g_print ("%s", "usage: mu find [options] \n"); } - - - MuError mu_cmd_find (MuStore *store, MuConfig *opts, GError **err) { diff --git a/mu/mu-cmd-index.c b/mu/mu-cmd-index.c index a36db383..6951de4d 100644 --- a/mu/mu-cmd-index.c +++ b/mu/mu-cmd-index.c @@ -243,23 +243,25 @@ show_time (unsigned t, unsigned processed, gboolean color) if (color) { if (t) - g_message ("elapsed: " + g_print ("elapsed: " MU_COLOR_GREEN "%u" MU_COLOR_DEFAULT " second(s), ~ " MU_COLOR_GREEN "%u" MU_COLOR_DEFAULT " msg/s", t, processed/t); else - g_message ("elapsed: " + g_print ("elapsed: " MU_COLOR_GREEN "%u" MU_COLOR_DEFAULT " second(s)", t); } else { if (t) - g_message ("elapsed: %u second(s), ~ %u msg/s", + g_print ("elapsed: %u second(s), ~ %u msg/s", t, processed/t); else - g_message ("elapsed: %u second(s)", t); + g_print ("elapsed: %u second(s)", t); } + + g_print ("\n"); } @@ -272,8 +274,9 @@ cleanup_missing (MuIndex *midx, MuConfig *opts, MuIndexStats *stats, time_t t; IndexData idata; - g_message ("cleaning up messages [%s]", - mu_runtime_path (MU_RUNTIME_PATH_XAPIANDB)); + if (!opts->quiet) + g_print ("cleaning up messages [%s]\n", + mu_runtime_path (MU_RUNTIME_PATH_XAPIANDB)); mu_index_stats_clear (stats); @@ -301,13 +304,13 @@ static void index_title (const char* maildir, const char* xapiandir, gboolean color) { if (color) - g_message ("indexing messages under " + g_print ("indexing messages under " MU_COLOR_BLUE "%s" MU_COLOR_DEFAULT " [" MU_COLOR_BLUE "%s" MU_COLOR_DEFAULT - "]", maildir, xapiandir); + "]\n", maildir, xapiandir); else - g_message ("indexing messages under %s [%s]", + g_print ("indexing messages under %s [%s]\n", maildir, xapiandir); } @@ -322,8 +325,9 @@ cmd_index (MuIndex *midx, MuConfig *opts, MuIndexStats *stats, t = time (NULL); - index_title (opts->maildir, mu_runtime_path(MU_RUNTIME_PATH_XAPIANDB), - !opts->nocolor); + if (!opts->quiet) + index_title (opts->maildir, mu_runtime_path(MU_RUNTIME_PATH_XAPIANDB), + !opts->nocolor); idata.color = !opts->nocolor; rv = mu_index_run (midx, opts->maildir, opts->reindex, stats, @@ -395,9 +399,6 @@ mu_cmd_index (MuStore *store, MuConfig *opts, GError **err) if (!midx) return MU_G_ERROR_CODE(err); - /* note, 'opts->quiet' already cause g_message output not to - * be shown; here, we make sure we only print progress info if - * opts->quiet is false case and when stdout is a tty */ show_progress = !opts->quiet && isatty(fileno(stdout)); mu_index_stats_clear (&stats); diff --git a/mu/mu-cmd.c b/mu/mu-cmd.c index 491b7be8..c79c4813 100644 --- a/mu/mu-cmd.c +++ b/mu/mu-cmd.c @@ -322,7 +322,7 @@ mu_cmd_add (MuStore *store, MuConfig *opts, GError **err) /* note: params[0] will be 'add' */ if (!opts->params[0] || !opts->params[1]) { - g_message ("usage: mu add []"); + g_print ("usage: mu add []\n"); g_set_error (err, MU_ERROR_DOMAIN, MU_ERROR_IN_PARAMETERS, "missing source and/or target"); return MU_ERROR_IN_PARAMETERS; @@ -394,11 +394,11 @@ mu_cmd_remove (MuStore *store, MuConfig *opts, GError **err) static void show_usage (void) { - g_message ("usage: mu command [options] [parameters]"); - g_message ("where command is one of index, find, cfind, view, mkdir, " - "extract, add, remove or server"); - g_message ("see the mu, mu- or mu-easy manpages for " - "more information"); + g_print ("usage: mu command [options] [parameters]\n"); + g_print ("where command is one of index, find, cfind, view, mkdir, " + "extract, add, remove or server\n"); + g_print ("see the mu, mu- or mu-easy manpages for " + "more information\n"); } static void