2
** Copyright (C) 2011 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.
21
#endif /*HAVE_CONFIG_H*/
23
#include <mu-runtime.h>
24
#include <glib-object.h>
26
#include <libmuguile/mu-guile-common.h>
27
#include <libmuguile/mu-guile-msg.h>
33
typedef struct _MuileConfig MuileConfig;
37
muile_config_new (int *argcp, char ***argvp)
40
MuileConfig *opts = g_new0 (MuileConfig, 1);
41
GOptionEntry entries[] = {
42
{"muhome", 0, 0, G_OPTION_ARG_FILENAME, &opts->muhome,
43
"specify an alternative mu directory", NULL},
44
{"msg", 0, 0, G_OPTION_ARG_FILENAME, &opts->msgpath,
45
"specify path to a message to load as mu:current-msg)", NULL},
46
{NULL, 0, 0, G_OPTION_ARG_NONE, NULL, NULL, NULL}/* sentinel */
49
octx = g_option_context_new ("- muile options");
50
g_option_context_add_main_entries (octx, entries, "Muile");
52
if (!g_option_context_parse (octx, argcp, argvp, NULL)) {
53
g_option_context_free (octx);
54
g_printerr ("muile: error in options\n");
59
opts->msgpath = mu_util_dir_expand (opts->msgpath);
61
g_option_context_free (octx);
67
muile_config_destroy (MuileConfig *conf)
69
g_free (conf->msgpath);
77
g_print ("usage: muile [--muhome=<dir>] [msgfile]\n");
82
main (int argc, char *argv[])
88
#ifdef HAVE_PRE2_GUILE
89
g_warning ("Note: muile will not function correctly unless you have a "
91
#endif /* HAVE_PRE2_GUILE */
93
opts = muile_config_new (&argc, &argv);
99
if (!mu_runtime_init (opts->muhome /* NULL is okay */,
105
mu_guile_init (); /* initialize mu guile modules */
108
if (!(gboolean)scm_with_guile
109
((MuGuileFunc*)&mu_guile_msg_load_current, opts->msgpath))
114
scm_shell (argc, argv);
116
mu_runtime_uninit ();
117
muile_config_destroy (opts);
122
muile_config_destroy (opts);