2
** Copyright (C) 2010 Dirk-Jan C. Binnema <djcb@djcbsoftware.nl>
4
** This program is free software; you can redistribute it and/or modify it
5
** under the terms of the GNU General Public License as published by the
6
** Free Software Foundation; either version 3, or (at your option) any
9
** This program is distributed in the hope that it will be useful,
10
** but WITHOUT ANY WARRANTY; without even the implied warranty of
11
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
** GNU General Public License for more details.
14
** You should have received a copy of the GNU General Public License
15
** along with this program; if not, write to the Free Software Foundation,
16
** Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
23
#include <string.h> /* memset */
26
#include "mu-config.h"
30
mu_config_options_group_mu (MuConfigOptions *opts)
33
GOptionEntry entries[] = {
34
{ "debug", 'd', 0, G_OPTION_ARG_NONE, &opts->debug,
35
"print debug output to standard error", NULL },
36
{ "quiet", 'q', 0, G_OPTION_ARG_NONE, &opts->quiet,
37
"don't give any progress information", NULL },
38
{"version", 'v', 0, G_OPTION_ARG_NONE, &opts->version,
39
"display version and copyright information", NULL},
40
{"muhome", 'a', 0, G_OPTION_ARG_FILENAME, &opts->muhome,
41
"specify an alternative mu directory ", NULL},
42
{"log-stderr", 'e', 0, G_OPTION_ARG_NONE, &opts->log_stderr,
43
"log to standard error", NULL},
44
{ G_OPTION_REMAINING, 0, 0, G_OPTION_ARG_STRING_ARRAY,
45
&opts->params, "parameters", NULL },
46
{ NULL, 0, 0, 0, NULL, NULL, NULL }
49
og = g_option_group_new ("mu",
52
g_option_group_add_entries (og, entries);
60
mu_config_options_group_index (MuConfigOptions *opts)
63
GOptionEntry entries[] = {
64
{"maildir", 'm', 0, G_OPTION_ARG_FILENAME, &opts->maildir,
65
"top of the maildir", NULL},
66
{"reindex", 'r', 0, G_OPTION_ARG_NONE, &opts->reindex,
67
"index already indexed messages too", NULL},
68
{"nocleanup", 'u', 0, G_OPTION_ARG_NONE, &opts->nocleanup,
69
"don't clean up the database after indexing", NULL},
70
{ NULL, 0, 0, 0, NULL, NULL, NULL }
73
og = g_option_group_new ("index",
74
"options for the 'index' command",
76
g_option_group_add_entries (og, entries);
82
mu_config_options_group_find (MuConfigOptions *opts)
85
GOptionEntry entries[] = {
86
{"xquery", 'x', 0, G_OPTION_ARG_NONE, &opts->xquery,
87
"print the Xapian query", NULL},
88
{"fields", 'f', 0, G_OPTION_ARG_STRING, &opts->fields,
89
"fields to display in the output", NULL},
90
{"sortfield", 's', 0, G_OPTION_ARG_STRING, &opts->sortfield,
91
"field to sort on", NULL},
92
{"descending", 'z', 0, G_OPTION_ARG_NONE, &opts->descending,
93
"sort in descending order (z -> a)", NULL},
94
{"linksdir", 'l', 0, G_OPTION_ARG_STRING, &opts->linksdir,
95
"output as symbolic links to a target maildir", NULL },
96
{"clearlinks", 'c', 0, G_OPTION_ARG_NONE, &opts->clearlinks,
97
"clear old links before filling a linksdir", NULL},
98
{ NULL, 0, 0, 0, NULL, NULL, NULL }
101
og = g_option_group_new ("find",
102
"options for the 'find' command",
104
g_option_group_add_entries (og, entries);
111
mu_config_init (MuConfigOptions *opts)
113
g_return_if_fail (opts);
115
/* start from zero */
116
memset (opts, 0, sizeof(MuConfigOptions));
124
home = g_getenv ("HOME");
126
home = g_get_home_dir ();
129
MU_WRITE_LOG ("failed to determine homedir");
131
return g_strdup_printf ("%s%c%s", home ? home : ".", G_DIR_SEPARATOR,
137
mu_config_set_defaults (MuConfigOptions *opts)
140
g_return_if_fail (opts);
143
opts->muhome = guess_muhome ();
145
/* note: xpath is is *not* settable from the cmdline */
146
opts->xpath = g_strdup_printf ("%s%c%s", opts->muhome,G_DIR_SEPARATOR,
152
opts->maildir = mu_util_dir_expand (opts->maildir);
154
opts->maildir = mu_util_guess_maildir();
159
/* note, when no fields are specified, we use
160
* date-from-subject, and sort descending by date. If fields
161
* *are* specified, we sort in ascending order. */
163
opts->descending = TRUE;
164
opts->fields = "d f s";
165
opts->sortfield = "d";
168
if (opts->linksdir) {
169
gchar *old = opts->linksdir;
170
opts->linksdir = mu_util_dir_expand (opts->linksdir);
177
mu_config_uninit (MuConfigOptions *opts)
179
g_return_if_fail (opts);
181
g_free (opts->muhome);
182
g_free (opts->xpath);
183
g_free (opts->maildir);
184
g_free (opts->linksdir);
186
g_strfreev (opts->params);