2009-11-28 13:06:21 +01:00
|
|
|
/*
|
2010-01-01 14:56:45 +01:00
|
|
|
** Copyright (C) 2010 Dirk-Jan C. Binnema <djcb@djcbsoftware.nl>
|
2009-11-28 13:06:21 +01:00
|
|
|
**
|
|
|
|
** This program is free software; you can redistribute it and/or modify it
|
|
|
|
** under the terms of the GNU General Public License as published by the
|
|
|
|
** Free Software Foundation; either version 3, or (at your option) any
|
|
|
|
** later version.
|
|
|
|
**
|
|
|
|
** This program is distributed in the hope that it will be useful,
|
|
|
|
** but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
** GNU General Public License for more details.
|
|
|
|
**
|
|
|
|
** You should have received a copy of the GNU General Public License
|
|
|
|
** along with this program; if not, write to the Free Software Foundation,
|
|
|
|
** Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
|
|
**
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <glib.h>
|
|
|
|
#include <string.h> /* memset */
|
2009-11-29 23:04:16 +01:00
|
|
|
|
|
|
|
#include "mu-util.h"
|
2009-11-28 13:06:21 +01:00
|
|
|
#include "mu-config.h"
|
|
|
|
|
|
|
|
|
|
|
|
GOptionGroup*
|
|
|
|
mu_config_options_group_mu (MuConfigOptions *opts)
|
|
|
|
{
|
|
|
|
GOptionGroup *og;
|
|
|
|
GOptionEntry entries[] = {
|
2009-12-11 18:45:37 +01:00
|
|
|
{ "debug", 'g', 0, G_OPTION_ARG_NONE, &opts->debug,
|
2009-12-23 23:41:56 +01:00
|
|
|
"print debug output to standard error", NULL },
|
2009-11-28 13:06:21 +01:00
|
|
|
{ "quiet", 'q', 0, G_OPTION_ARG_NONE, &opts->quiet,
|
|
|
|
"don't give any progress information", NULL },
|
2009-11-28 19:55:50 +01:00
|
|
|
{"version", 'v', 0, G_OPTION_ARG_NONE, &opts->version,
|
|
|
|
"display version and copyright information", NULL},
|
|
|
|
{"muhome", 'h', 0, G_OPTION_ARG_FILENAME, &opts->muhome,
|
|
|
|
"mu directory", NULL},
|
2009-12-11 18:45:37 +01:00
|
|
|
{"log-stderr", 'e', 0, G_OPTION_ARG_NONE, &opts->log_stderr,
|
2009-11-28 19:55:50 +01:00
|
|
|
"log to standard error", NULL},
|
|
|
|
{"log-append", 'a', 0, G_OPTION_ARG_NONE, &opts->log_append,
|
2009-12-23 23:41:56 +01:00
|
|
|
"append to the logfile (instead of overwriting)",
|
2009-11-28 19:55:50 +01:00
|
|
|
NULL},
|
2009-12-11 21:04:54 +01:00
|
|
|
{ G_OPTION_REMAINING, 0, 0, G_OPTION_ARG_STRING_ARRAY,
|
|
|
|
&opts->params, "parameters", NULL },
|
2009-12-08 23:02:55 +01:00
|
|
|
{ NULL, 0, 0, 0, NULL, NULL, NULL }
|
2009-11-28 13:06:21 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
og = g_option_group_new ("mu",
|
|
|
|
"general mu options",
|
|
|
|
"", NULL, NULL);
|
|
|
|
g_option_group_add_entries (og, entries);
|
|
|
|
|
|
|
|
return og;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
GOptionGroup*
|
|
|
|
mu_config_options_group_index (MuConfigOptions *opts)
|
|
|
|
{
|
|
|
|
GOptionGroup *og;
|
|
|
|
GOptionEntry entries[] = {
|
|
|
|
{"maildir", 'm', 0, G_OPTION_ARG_FILENAME, &opts->maildir,
|
|
|
|
"top of the maildir", NULL},
|
|
|
|
{"reindex", 'r', 0, G_OPTION_ARG_NONE, &opts->reindex,
|
2009-12-23 23:41:56 +01:00
|
|
|
"index even already indexed messages ", NULL},
|
2009-12-08 23:02:55 +01:00
|
|
|
{ NULL, 0, 0, 0, NULL, NULL, NULL }
|
2009-11-28 13:06:21 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
og = g_option_group_new ("index",
|
|
|
|
"options for the 'index' command",
|
|
|
|
"", NULL, NULL);
|
|
|
|
g_option_group_add_entries (og, entries);
|
|
|
|
|
|
|
|
return og;
|
|
|
|
}
|
|
|
|
|
|
|
|
GOptionGroup*
|
|
|
|
mu_config_options_group_query (MuConfigOptions *opts)
|
|
|
|
{
|
|
|
|
GOptionGroup *og;
|
|
|
|
GOptionEntry entries[] = {
|
|
|
|
{"xquery", 'x', 0, G_OPTION_ARG_NONE, &opts->xquery,
|
2009-12-11 18:45:37 +01:00
|
|
|
"print the Xapian query", NULL},
|
2009-11-28 13:06:21 +01:00
|
|
|
{"fields", 'f', 0, G_OPTION_ARG_STRING, &opts->fields,
|
2009-12-23 23:41:56 +01:00
|
|
|
"fields to display in the output", NULL},
|
2009-12-11 22:55:35 +01:00
|
|
|
{"sortfield", 's', 0, G_OPTION_ARG_STRING, &opts->sortfield,
|
2009-11-28 13:06:21 +01:00
|
|
|
"field to sort on", NULL},
|
2009-12-11 22:55:35 +01:00
|
|
|
{"ascending", 'u', 0, G_OPTION_ARG_NONE, &opts->ascending,
|
2009-12-11 18:45:37 +01:00
|
|
|
"sort ascending (up)", NULL},
|
2009-12-11 22:55:35 +01:00
|
|
|
{"descending", 'd', 0, G_OPTION_ARG_NONE, &opts->descending,
|
2009-12-11 18:45:37 +01:00
|
|
|
"sort descending (down)", NULL},
|
2010-01-01 14:37:39 +01:00
|
|
|
{"linksdir", 't', 0, G_OPTION_ARG_STRING, &opts->linksdir,
|
|
|
|
"output as symbolic links to a target maildir", NULL },
|
2009-12-08 23:02:55 +01:00
|
|
|
{ NULL, 0, 0, 0, NULL, NULL, NULL }
|
2009-11-28 13:06:21 +01:00
|
|
|
};
|
|
|
|
|
2009-12-11 18:45:37 +01:00
|
|
|
og = g_option_group_new ("query",
|
2009-11-28 13:06:21 +01:00
|
|
|
"options for the 'query' command",
|
|
|
|
"", NULL, NULL);
|
|
|
|
g_option_group_add_entries (og, entries);
|
|
|
|
|
|
|
|
return og;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
2009-11-29 23:04:16 +01:00
|
|
|
mu_config_init (MuConfigOptions *opts)
|
2009-11-28 13:06:21 +01:00
|
|
|
{
|
|
|
|
g_return_if_fail (opts);
|
|
|
|
|
|
|
|
/* start from zero */
|
|
|
|
memset (opts, 0, sizeof(MuConfigOptions));
|
|
|
|
|
|
|
|
/* general */
|
2009-12-05 19:11:18 +01:00
|
|
|
opts->quiet = FALSE;
|
|
|
|
opts->debug = FALSE;
|
|
|
|
opts->muhome = mu_util_dir_expand ("~/.mu");
|
|
|
|
opts->log_append = TRUE;
|
|
|
|
opts->log_stderr = FALSE;
|
2009-11-28 13:06:21 +01:00
|
|
|
|
2009-12-09 18:53:30 +01:00
|
|
|
/* indexing */
|
2010-01-01 19:44:19 +01:00
|
|
|
opts->maildir = mu_util_guess_maildir();
|
2009-11-28 13:06:21 +01:00
|
|
|
opts->cleanup = FALSE;
|
|
|
|
opts->reindex = FALSE;
|
|
|
|
|
|
|
|
/* querying */
|
2010-01-01 19:44:19 +01:00
|
|
|
opts->xquery = FALSE;
|
|
|
|
opts->fields = "d f s";
|
|
|
|
opts->sortfield = "d";
|
|
|
|
opts->ascending = FALSE;
|
|
|
|
opts->descending = TRUE;
|
|
|
|
opts->linksdir = NULL;
|
2009-11-28 13:06:21 +01:00
|
|
|
}
|
2009-11-29 23:04:16 +01:00
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
mu_config_uninit (MuConfigOptions *opts)
|
|
|
|
{
|
|
|
|
g_return_if_fail (opts);
|
|
|
|
|
2010-01-01 14:37:39 +01:00
|
|
|
g_free (opts->muhome);
|
|
|
|
g_free (opts->maildir);
|
|
|
|
g_free (opts->linksdir);
|
2010-01-01 19:44:19 +01:00
|
|
|
|
2009-12-11 21:04:54 +01:00
|
|
|
g_strfreev (opts->params);
|
2009-11-29 23:04:16 +01:00
|
|
|
}
|
2009-12-31 13:25:20 +01:00
|
|
|
|
2010-01-01 19:44:19 +01:00
|
|
|
|