summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorDirk-Jan C. Binnema <djcb@djcbsoftware.nl>2010-11-30 09:02:29 +0200
committerDirk-Jan C. Binnema <djcb@djcbsoftware.nl>2010-11-30 09:02:29 +0200
commit2b393ed7c56f3be731058bc60c8cb9ac48b23de6 (patch)
treea894510570e3f3db2e350b1c8fb575696552af6f /src
parent00bd5e1c87a7844a3e2a4afb1fd7da1e31a3372e (diff)
* make error messages more consistent
Diffstat (limited to 'src')
-rw-r--r--src/mu-cmd-extract.c17
-rw-r--r--src/mu-cmd-find.c18
-rw-r--r--src/mu-cmd-index.c18
-rw-r--r--src/mu-cmd-mkdir.c4
-rw-r--r--src/mu-cmd-view.c2
-rw-r--r--src/mu-config.c2
-rw-r--r--src/mu-str-normalize.c1
7 files changed, 36 insertions, 26 deletions
diff --git a/src/mu-cmd-extract.c b/src/mu-cmd-extract.c
index 4627cb1..2201688 100644
--- a/src/mu-cmd-extract.c
+++ b/src/mu-cmd-extract.c
@@ -17,7 +17,7 @@
**
*/
-#ifdef HAVE_CONFIG_H
+#if HAVE_CONFIG_H
#include "config.h"
#endif /*HAVE_CONFIG_H*/
@@ -84,7 +84,8 @@ save_part_if (MuMsgPart *part, SaveData *sd)
* the attachment check may be a bit too strict */
if (sd->attachments_only)
if (!part->disposition ||
- ((g_ascii_strcasecmp (part->disposition, "attachment") != 0) &&
+ ((g_ascii_strcasecmp (part->disposition,
+ "attachment") != 0) &&
g_ascii_strcasecmp (part->disposition, "inline")))
return;
@@ -103,8 +104,8 @@ save_part_if (MuMsgPart *part, SaveData *sd)
}
static gboolean
-save_certain_parts (MuMsg *msg, gboolean attachments_only, const gchar *targetdir,
- gboolean overwrite)
+save_certain_parts (MuMsg *msg, gboolean attachments_only,
+ const gchar *targetdir, gboolean overwrite)
{
SaveData sd;
@@ -204,17 +205,19 @@ static gboolean
check_params (MuConfigOptions *opts)
{
if (!opts->params[1]) {
- g_warning ("missing mail file to extract something from");
+ g_warning ("usage: mu extract [options] <file>");
return FALSE;
}
if (!mu_util_check_dir(opts->targetdir, FALSE, TRUE)) {
- g_warning ("target '%s' is not a writable directory", opts->targetdir);
+ g_warning ("target '%s' is not a writable directory",
+ opts->targetdir);
return FALSE;
}
if (opts->save_attachments && opts->save_all) {
- g_warning ("only one of --save-attachments and --save-all is allowed");
+ g_warning ("only one of --save-attachments and"
+ " --save-all is allowed");
return FALSE;
}
diff --git a/src/mu-cmd-find.c b/src/mu-cmd-find.c
index b00c307..24dd069 100644
--- a/src/mu-cmd-find.c
+++ b/src/mu-cmd-find.c
@@ -64,7 +64,7 @@ print_xapian_query (MuQuery *xapian, const gchar *query)
err = NULL;
querystr = mu_query_as_string (xapian, query, &err);
if (!querystr) {
- g_warning ("Error: %s", err->message);
+ g_warning ("error: %s", err->message);
g_error_free (err);
return FALSE;
}
@@ -156,7 +156,7 @@ run_query (MuQuery *xapian, const gchar *query, MuConfigOptions *opts)
iter = mu_query_run (xapian, query, sortid,
opts->descending ? FALSE : TRUE, 0, &err);
if (!iter) {
- g_warning ("Error: %s", err->message);
+ g_warning ("error: %s", err->message);
g_error_free (err);
return FALSE;
}
@@ -169,7 +169,7 @@ run_query (MuQuery *xapian, const gchar *query, MuConfigOptions *opts)
opts->summary_len);
if (matches == 0)
- g_printerr ("No matches found\n");
+ g_warning ("No matches found");
mu_msg_iter_destroy (iter);
@@ -184,7 +184,7 @@ query_params_valid (MuConfigOptions *opts)
if (opts->linksdir)
if (opts->xquery) {
- g_printerr ("Invalid option for '--linksdir'\n");
+ g_warning ("invalid option for --linksdir");
return FALSE;
}
@@ -209,13 +209,13 @@ resolve_bookmark (MuConfigOptions *opts)
bmfile = mu_runtime_bookmarks_file();
bm = mu_bookmarks_new (bmfile);
if (!bm) {
- g_warning ("Failed to open bookmarks file '%s'", bmfile);
+ g_warning ("failed to open bookmarks file '%s'", bmfile);
return FALSE;
}
val = (gchar*)mu_bookmarks_lookup (bm, opts->bookmark);
if (!val)
- g_warning ("Bookmark '%s' not found", opts->bookmark);
+ g_warning ("bookmark '%s' not found", opts->bookmark);
else
val = g_strdup (val);
@@ -232,7 +232,7 @@ get_query (MuConfigOptions *opts)
/* params[0] is 'find', actual search params start with [1] */
if (!opts->bookmark && !opts->params[1]) {
- g_warning ("Empty search query");
+ g_warning ("usage: mu find [options] search-expression");
return FALSE;
}
@@ -260,7 +260,7 @@ static gboolean
db_is_ready (const char *xpath)
{
if (mu_util_db_is_empty (xpath)) {
- g_warning ("Database is empty; use 'mu index' to "
+ g_warning ("database is empty; use 'mu index' to "
"add messages");
return FALSE;
}
@@ -301,7 +301,7 @@ mu_cmd_find (MuConfigOptions *opts)
err = NULL;
xapian = mu_query_new (xpath, &err);
if (!xapian) {
- g_warning ("Error: %s", err->message);
+ g_warning ("error: %s", err->message);
g_error_free (err);
return FALSE;
}
diff --git a/src/mu-cmd-index.c b/src/mu-cmd-index.c
index ddc17e8..24d5b66 100644
--- a/src/mu-cmd-index.c
+++ b/src/mu-cmd-index.c
@@ -78,8 +78,15 @@ install_sig_handler (void)
static gboolean
-check_index_params (MuConfigOptions *opts)
+check_index_or_cleanup_params (MuConfigOptions *opts)
{
+ /* param[0] == 'index' or 'cleanup', there should be no
+ * param[1] */
+ if (opts->params[1]) {
+ g_warning ("usage: mu %s [options]", opts->params[0]);
+ return FALSE;
+ }
+
if (opts->linksdir || opts->xquery) {
g_warning ("invalid option(s) for command");
return FALSE;
@@ -223,10 +230,10 @@ cmd_index (MuIndex *midx, MuConfigOptions *opts, MuIndexStats *stats,
g_message ("Indexing messages under %s [%s]", opts->maildir,
mu_runtime_xapian_dir());
-
+
t = time (NULL);
rv = mu_index_run (midx, opts->maildir, opts->reindex, stats,
- show_progress ? index_msg_cb : index_msg_silent_cb,
+ show_progress ? index_msg_cb:index_msg_silent_cb,
NULL, NULL);
if (!opts->quiet) {
@@ -241,7 +248,8 @@ cmd_index (MuIndex *midx, MuConfigOptions *opts, MuIndexStats *stats,
}
if (rv == MU_OK || rv == MU_STOP) {
- MU_WRITE_LOG ("processed: %u; updated/new: %u, cleaned-up: %u",
+ MU_WRITE_LOG ("processed: %u; updated/new: %u, "
+ "cleaned-up: %u",
stats->_processed, stats->_updated,
stats->_cleaned_up);
return TRUE;
@@ -265,7 +273,7 @@ cmd_index_or_cleanup (MuConfigOptions *opts)
g_return_val_if_fail (mu_cmd_equals (opts, "index") ||
mu_cmd_equals (opts, "cleanup"), FALSE);
- if (!check_index_params (opts) ||
+ if (!check_index_or_cleanup_params (opts) ||
!database_version_check_and_update(opts))
return FALSE;
diff --git a/src/mu-cmd-mkdir.c b/src/mu-cmd-mkdir.c
index fa29e5b..7cff0a3 100644
--- a/src/mu-cmd-mkdir.c
+++ b/src/mu-cmd-mkdir.c
@@ -39,9 +39,9 @@ mu_cmd_mkdir (MuConfigOptions *opts)
g_return_val_if_fail (mu_cmd_equals (opts, "mkdir"), FALSE);
if (!opts->params[1]) {
- g_printerr (
+ g_warning (
"usage: mu mkdir [-u,--mode=<mode>] "
- "<dir> [more dirs]\n");
+ "<dir> [more dirs]");
return FALSE;
}
diff --git a/src/mu-cmd-view.c b/src/mu-cmd-view.c
index c40559e..fd00c11 100644
--- a/src/mu-cmd-view.c
+++ b/src/mu-cmd-view.c
@@ -73,7 +73,7 @@ mu_cmd_view (MuConfigOptions *opts)
/* note: params[0] will be 'view' */
if (!opts->params[0] || !opts->params[1]) {
- g_printerr ("Missing files to view\n");
+ g_warning ("usage: mu view [options] <file> [<files>]");
return FALSE;
}
diff --git a/src/mu-config.c b/src/mu-config.c
index 8f18f01..9df5559 100644
--- a/src/mu-config.c
+++ b/src/mu-config.c
@@ -256,7 +256,7 @@ parse_params (MuConfigOptions *opts, int *argcp, char ***argvp)
err = NULL;
rv = g_option_context_parse (context, argcp, argvp, &err);
if (!rv) {
- g_printerr ("error in options: %s\n", err->message);
+ g_warning ("error in options: %s\n", err->message);
g_error_free (err);
}
diff --git a/src/mu-str-normalize.c b/src/mu-str-normalize.c
index f35d298..d5fa801 100644
--- a/src/mu-str-normalize.c
+++ b/src/mu-str-normalize.c
@@ -81,7 +81,6 @@ mu_str_normalize_in_place (char *str, gboolean downcase)
case 0x89:
case 0x8a:
case 0x8b:
- g_printerr ("<%c>", downcase ? 'e' : 'E');
str[i++] = downcase ? 'e' : 'E';
break;