* some fixes for the help system

This commit is contained in:
djcb 2012-09-19 10:44:16 +03:00
parent 257374076c
commit 7d8a58896e
4 changed files with 32 additions and 10 deletions

View File

@ -154,13 +154,16 @@ config_options_group_index (void)
&MU_CONFIG.my_addresses, &MU_CONFIG.my_addresses,
"my e-mail address (regexp); can be used multiple times", "my e-mail address (regexp); can be used multiple times",
"<address>"}, "<address>"},
{"autoupgrade", 0, 0, G_OPTION_ARG_NONE, &MU_CONFIG.autoupgrade, {"autoupgrade", 0, 0, G_OPTION_ARG_NONE,
"auto-upgrade the database with new mu versions (false)", NULL}, &MU_CONFIG.autoupgrade,
"auto-upgrade the database with new mu versions (false)",
NULL},
{"nocleanup", 0, 0, G_OPTION_ARG_NONE, &MU_CONFIG.nocleanup, {"nocleanup", 0, 0, G_OPTION_ARG_NONE, &MU_CONFIG.nocleanup,
"don't clean up the database after indexing (false)", NULL}, "don't clean up the database after indexing (false)", NULL},
{"xbatchsize", 0, 0, G_OPTION_ARG_INT, &MU_CONFIG.xbatchsize, {"xbatchsize", 0, 0, G_OPTION_ARG_INT, &MU_CONFIG.xbatchsize,
"set transaction batchsize for xapian commits (0)", NULL}, "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", "<size>"}, "set the maximum size for message files", "<size>"},
{NULL, 0, 0, 0, NULL, NULL, NULL} {NULL, 0, 0, 0, NULL, NULL, NULL}
}; };
@ -201,7 +204,8 @@ config_options_group_find (void)
GOptionEntry entries[] = { GOptionEntry entries[] = {
{"fields", 'f', 0, G_OPTION_ARG_STRING, &MU_CONFIG.fields, {"fields", 'f', 0, G_OPTION_ARG_STRING, &MU_CONFIG.fields,
"fields to display in the output", "<fields>"}, "fields to display in the output", "<fields>"},
{"sortfield", 's', 0, G_OPTION_ARG_STRING, &MU_CONFIG.sortfield, {"sortfield", 's', 0, G_OPTION_ARG_STRING,
&MU_CONFIG.sortfield,
"field to sort on", "<field>"}, "field to sort on", "<field>"},
{"threads", 't', 0, G_OPTION_ARG_NONE, &MU_CONFIG.threads, {"threads", 't', 0, G_OPTION_ARG_NONE, &MU_CONFIG.threads,
"show message threads", NULL}, "show message threads", NULL},
@ -219,7 +223,8 @@ config_options_group_find (void)
{"exec", 'e', 0, G_OPTION_ARG_STRING, &MU_CONFIG.exec, {"exec", 'e', 0, G_OPTION_ARG_STRING, &MU_CONFIG.exec,
"execute command on each match message", "<command>"}, "execute command on each match message", "<command>"},
{"after", 0, 0, G_OPTION_ARG_INT, &MU_CONFIG.after, {"after", 0, 0, G_OPTION_ARG_INT, &MU_CONFIG.after,
"only show messages whose m_time > T (t_time)", "<timestamp>"}, "only show messages whose m_time > T (t_time)",
"<timestamp>"},
{NULL, 0, 0, 0, NULL, NULL, NULL} {NULL, 0, 0, 0, NULL, NULL, NULL}
}; };
@ -361,7 +366,8 @@ config_options_group_extract (void)
"save all parts (incl. non-attachments) (false)", NULL}, "save all parts (incl. non-attachments) (false)", NULL},
{"parts", 0, 0, G_OPTION_ARG_STRING, &MU_CONFIG.parts, {"parts", 0, 0, G_OPTION_ARG_STRING, &MU_CONFIG.parts,
"save specific parts (comma-separated list)", "<parts>"}, "save specific parts (comma-separated list)", "<parts>"},
{"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", "<dir>"}, "target directory for saving", "<dir>"},
{"overwrite", 0, 0, G_OPTION_ARG_NONE, &MU_CONFIG.overwrite, {"overwrite", 0, 0, G_OPTION_ARG_NONE, &MU_CONFIG.overwrite,
"overwrite existing files (false)", NULL}, "overwrite existing files (false)", NULL},
@ -370,7 +376,7 @@ config_options_group_extract (void)
{NULL, 0, 0, 0, NULL, NULL, NULL} {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", og = g_option_group_new("extract",
"Options for the 'extract' command", "Options for the 'extract' command",
@ -544,6 +550,8 @@ mu_config_show_help (MuConfigCmd cmd)
GOptionGroup *group; GOptionGroup *group;
char *cleanhelp; char *cleanhelp;
g_return_if_fail (mu_config_cmd_is_valid(cmd));
ctx = g_option_context_new (""); ctx = g_option_context_new ("");
g_option_context_set_main_group (ctx, config_options_group_mu()); g_option_context_set_main_group (ctx, config_options_group_mu());

View File

@ -81,6 +81,10 @@ enum _MuConfigCmd {
typedef enum _MuConfigCmd 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 /* struct with all configuration options for mu; it will be filled
* from the config file, and/or command line arguments */ * from the config file, and/or command line arguments */

View File

@ -1,4 +1,5 @@
#-*-mode:org-*- #-*-mode:org-*-
#
# Copyright (C) 2012 Dirk-Jan C. Binnema <djcb@djcbsoftware.nl> # Copyright (C) 2012 Dirk-Jan C. Binnema <djcb@djcbsoftware.nl>
# #
# This program is free software; you can redistribute it and/or modify # This program is free software; you can redistribute it and/or modify

View File

@ -35,8 +35,16 @@
static void static void
show_version (void) show_version (void)
{ {
g_print ("mu (mail indexer/searcher) version " VERSION "\n" const char* blurb =
"Copyright (C) 2008-2012 Dirk-Jan C. Binnema (GPLv3+)\n"); "mu (mail indexer/searcher) version " VERSION "\n"
"Copyright (C) 2008-2012 Dirk-Jan C. Binnema\n"
"License GPLv3+: GNU GPL version 3 or later "
"<http://gnu.org/licenses/gpl.html>.\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'"); g_print ("database is empty; try 'mu index'");
break; break;
case MU_ERROR_IN_PARAMETERS: 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; break;
default:break; /* nothing to do */ default:break; /* nothing to do */
} }