diff --git a/mu/mu-config.c b/mu/mu-config.c
index e13491d8..a7a2bf26 100644
--- a/mu/mu-config.c
+++ b/mu/mu-config.c
@@ -154,13 +154,16 @@ config_options_group_index (void)
&MU_CONFIG.my_addresses,
"my e-mail address (regexp); can be used multiple times",
"
"},
- {"autoupgrade", 0, 0, G_OPTION_ARG_NONE, &MU_CONFIG.autoupgrade,
- "auto-upgrade the database with new mu versions (false)", NULL},
+ {"autoupgrade", 0, 0, G_OPTION_ARG_NONE,
+ &MU_CONFIG.autoupgrade,
+ "auto-upgrade the database with new mu versions (false)",
+ NULL},
{"nocleanup", 0, 0, G_OPTION_ARG_NONE, &MU_CONFIG.nocleanup,
"don't clean up the database after indexing (false)", NULL},
{"xbatchsize", 0, 0, G_OPTION_ARG_INT, &MU_CONFIG.xbatchsize,
"set transaction batchsize for xapian commits (0)", NULL},
- {"max-msg-size", 0, 0, G_OPTION_ARG_INT, &MU_CONFIG.max_msg_size,
+ {"max-msg-size", 0, 0, G_OPTION_ARG_INT,
+ &MU_CONFIG.max_msg_size,
"set the maximum size for message files", ""},
{NULL, 0, 0, 0, NULL, NULL, NULL}
};
@@ -201,7 +204,8 @@ config_options_group_find (void)
GOptionEntry entries[] = {
{"fields", 'f', 0, G_OPTION_ARG_STRING, &MU_CONFIG.fields,
"fields to display in the output", ""},
- {"sortfield", 's', 0, G_OPTION_ARG_STRING, &MU_CONFIG.sortfield,
+ {"sortfield", 's', 0, G_OPTION_ARG_STRING,
+ &MU_CONFIG.sortfield,
"field to sort on", ""},
{"threads", 't', 0, G_OPTION_ARG_NONE, &MU_CONFIG.threads,
"show message threads", NULL},
@@ -219,7 +223,8 @@ config_options_group_find (void)
{"exec", 'e', 0, G_OPTION_ARG_STRING, &MU_CONFIG.exec,
"execute command on each match message", ""},
{"after", 0, 0, G_OPTION_ARG_INT, &MU_CONFIG.after,
- "only show messages whose m_time > T (t_time)", ""},
+ "only show messages whose m_time > T (t_time)",
+ ""},
{NULL, 0, 0, 0, NULL, NULL, NULL}
};
@@ -361,7 +366,8 @@ config_options_group_extract (void)
"save all parts (incl. non-attachments) (false)", NULL},
{"parts", 0, 0, G_OPTION_ARG_STRING, &MU_CONFIG.parts,
"save specific parts (comma-separated list)", ""},
- {"target-dir", 0, 0, G_OPTION_ARG_FILENAME, &MU_CONFIG.targetdir,
+ {"target-dir", 0, 0, G_OPTION_ARG_FILENAME,
+ &MU_CONFIG.targetdir,
"target directory for saving", ""},
{"overwrite", 0, 0, G_OPTION_ARG_NONE, &MU_CONFIG.overwrite,
"overwrite existing files (false)", NULL},
@@ -370,7 +376,7 @@ config_options_group_extract (void)
{NULL, 0, 0, 0, NULL, NULL, NULL}
};
- MU_CONFIG.targetdir = g_strdup("."); /* default is the current dir */
+ MU_CONFIG.targetdir = g_strdup("."); /* default is the current dir */
og = g_option_group_new("extract",
"Options for the 'extract' command",
@@ -544,6 +550,8 @@ mu_config_show_help (MuConfigCmd cmd)
GOptionGroup *group;
char *cleanhelp;
+ g_return_if_fail (mu_config_cmd_is_valid(cmd));
+
ctx = g_option_context_new ("");
g_option_context_set_main_group (ctx, config_options_group_mu());
diff --git a/mu/mu-config.h b/mu/mu-config.h
index 6eb27e13..46bfc945 100644
--- a/mu/mu-config.h
+++ b/mu/mu-config.h
@@ -81,6 +81,10 @@ enum _MuConfigCmd {
typedef enum _MuConfigCmd MuConfigCmd;
+#define mu_config_cmd_is_valid(C) \
+ ((C) > MU_CONFIG_CMD_UNKNOWN && (C) < MU_CONFIG_CMD_NONE)
+
+
/* struct with all configuration options for mu; it will be filled
* from the config file, and/or command line arguments */
diff --git a/mu/mu-help-strings.txt b/mu/mu-help-strings.txt
index 0043bd23..1fd4f94d 100644
--- a/mu/mu-help-strings.txt
+++ b/mu/mu-help-strings.txt
@@ -1,4 +1,5 @@
#-*-mode:org-*-
+#
# Copyright (C) 2012 Dirk-Jan C. Binnema
#
# This program is free software; you can redistribute it and/or modify
diff --git a/mu/mu.cc b/mu/mu.cc
index e1eca949..096f9cb8 100644
--- a/mu/mu.cc
+++ b/mu/mu.cc
@@ -35,8 +35,16 @@
static void
show_version (void)
{
- g_print ("mu (mail indexer/searcher) version " VERSION "\n"
- "Copyright (C) 2008-2012 Dirk-Jan C. Binnema (GPLv3+)\n");
+ const char* blurb =
+ "mu (mail indexer/searcher) version " VERSION "\n"
+ "Copyright (C) 2008-2012 Dirk-Jan C. Binnema\n"
+ "License GPLv3+: GNU GPL version 3 or later "
+ ".\n"
+ "This is free software: you are free to change "
+ "and redistribute it.\n"
+ "There is NO WARRANTY, to the extent permitted by law.";
+
+ g_print ("%s\n", blurb);
}
@@ -58,7 +66,8 @@ handle_error (MuConfig *conf, GError *err)
g_print ("database is empty; try 'mu index'");
break;
case MU_ERROR_IN_PARAMETERS:
- mu_config_show_help (conf->cmd);
+ if (mu_config_cmd_is_valid(conf->cmd))
+ mu_config_show_help (conf->cmd);
break;
default:break; /* nothing to do */
}