mirror of https://github.com/djcb/mu.git
* mu, mu-config: add --version, prepare logging support
This commit is contained in:
parent
8c74e0569d
commit
bc99a753da
|
@ -31,6 +31,15 @@ mu_config_options_group_mu (MuConfigOptions *opts)
|
||||||
"print debug output to standard-error", NULL },
|
"print debug output to standard-error", NULL },
|
||||||
{ "quiet", 'q', 0, G_OPTION_ARG_NONE, &opts->quiet,
|
{ "quiet", 'q', 0, G_OPTION_ARG_NONE, &opts->quiet,
|
||||||
"don't give any progress information", NULL },
|
"don't give any progress information", NULL },
|
||||||
|
{"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},
|
||||||
|
{"log-stderr", 's', 0, G_OPTION_ARG_NONE, &opts->log_stderr,
|
||||||
|
"log to standard error", NULL},
|
||||||
|
{"log-append", 'a', 0, G_OPTION_ARG_NONE, &opts->log_append,
|
||||||
|
"append to the current logfile (instead of overwriting it)",
|
||||||
|
NULL},
|
||||||
{ NULL }
|
{ NULL }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -29,25 +29,29 @@
|
||||||
struct _MuConfigOptions {
|
struct _MuConfigOptions {
|
||||||
|
|
||||||
/* general options */
|
/* general options */
|
||||||
gboolean quiet; /* don't give any output */
|
gboolean quiet; /* don't give any output */
|
||||||
gboolean debug; /* spew out debug info */
|
gboolean debug; /* spew out debug info */
|
||||||
|
const char *muhome;/* the House of Mu */
|
||||||
|
gboolean version; /* request mu version */
|
||||||
|
gboolean log_stderr; /*log to stderr (instead of logfile)*/
|
||||||
|
gboolean log_append; /* append to log (instead of overwriting)*/
|
||||||
|
|
||||||
/* options for indexing */
|
/* options for indexing */
|
||||||
const char *maildir; /* where the mails are */
|
const char *maildir; /* where the mails are */
|
||||||
gboolean cleanup; /* cleanup deleted mails form db */
|
gboolean cleanup; /* cleanup deleted mails form db */
|
||||||
gboolean reindex; /* re-index existing mails */
|
gboolean reindex; /* re-index existing mails */
|
||||||
|
|
||||||
/* options for querying */
|
/* options for querying */
|
||||||
gboolean xquery; /* give the Xapian query instead of
|
gboolean xquery; /* give the Xapian query instead of
|
||||||
search results */
|
search results */
|
||||||
const char *fields; /* fields to show in output */
|
const char *fields; /* fields to show in output */
|
||||||
|
|
||||||
const char *sortfield_str; /* field to sort by (string) */
|
const char *sortfield_str; /* field to sort by (string) */
|
||||||
|
|
||||||
/* FIXME: clean up this mess */
|
/* FIXME: clean up this mess */
|
||||||
gboolean sortdir_descending ; /* sort descending? */
|
gboolean sortdir_descending ; /* sort descending? */
|
||||||
gboolean sortdir_ascending;
|
gboolean sortdir_ascending;
|
||||||
gboolean ascending_flag, descending_flag;
|
gboolean ascending_flag, descending_flag;
|
||||||
};
|
};
|
||||||
typedef struct _MuConfigOptions MuConfigOptions;
|
typedef struct _MuConfigOptions MuConfigOptions;
|
||||||
|
|
||||||
|
|
25
src/mu.c
25
src/mu.c
|
@ -17,6 +17,8 @@
|
||||||
**
|
**
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include <config.h>
|
||||||
|
|
||||||
#include <glib.h>
|
#include <glib.h>
|
||||||
#include <glib-object.h>
|
#include <glib-object.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
@ -84,6 +86,23 @@ show_help (const char* cmd)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
show_version (void)
|
||||||
|
{
|
||||||
|
const char* msg =
|
||||||
|
"mu (mail indexer / searcher version) " VERSION "\n\n"
|
||||||
|
"copyright (C) 2009 Dirk-Jan C. Binnema\n"
|
||||||
|
"license GPLv3+: GNU GPL version 3 or later "
|
||||||
|
"<http://gnu.org/licenses/gpl.html>.\n\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", msg);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
show_usage (gboolean noerror)
|
show_usage (gboolean noerror)
|
||||||
{
|
{
|
||||||
|
@ -99,7 +118,6 @@ show_usage (gboolean noerror)
|
||||||
|
|
||||||
return noerror ? 0 : 1;
|
return noerror ? 0 : 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
main (int argc, char *argv[])
|
main (int argc, char *argv[])
|
||||||
{
|
{
|
||||||
|
@ -128,10 +146,15 @@ main (int argc, char *argv[])
|
||||||
g_error_free (error);
|
g_error_free (error);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (config.version)
|
||||||
|
return show_version ();
|
||||||
|
|
||||||
if (argc < 2)
|
if (argc < 2)
|
||||||
return show_usage (FALSE);
|
return show_usage (FALSE);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
cmd = parse_cmd (argv[1]);
|
cmd = parse_cmd (argv[1]);
|
||||||
if (cmd == MU_CMD_UNKNOWN)
|
if (cmd == MU_CMD_UNKNOWN)
|
||||||
return show_usage (FALSE);
|
return show_usage (FALSE);
|
||||||
|
|
Loading…
Reference in New Issue