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 },
|
||||
{ "quiet", 'q', 0, G_OPTION_ARG_NONE, &opts->quiet,
|
||||
"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 }
|
||||
};
|
||||
|
||||
|
|
|
@ -29,25 +29,29 @@
|
|||
struct _MuConfigOptions {
|
||||
|
||||
/* general options */
|
||||
gboolean quiet; /* don't give any output */
|
||||
gboolean debug; /* spew out debug info */
|
||||
gboolean quiet; /* don't give any output */
|
||||
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 */
|
||||
const char *maildir; /* where the mails are */
|
||||
gboolean cleanup; /* cleanup deleted mails form db */
|
||||
gboolean reindex; /* re-index existing mails */
|
||||
const char *maildir; /* where the mails are */
|
||||
gboolean cleanup; /* cleanup deleted mails form db */
|
||||
gboolean reindex; /* re-index existing mails */
|
||||
|
||||
/* options for querying */
|
||||
gboolean xquery; /* give the Xapian query instead of
|
||||
gboolean xquery; /* give the Xapian query instead of
|
||||
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 */
|
||||
gboolean sortdir_descending ; /* sort descending? */
|
||||
gboolean sortdir_ascending;
|
||||
gboolean ascending_flag, descending_flag;
|
||||
gboolean sortdir_descending ; /* sort descending? */
|
||||
gboolean sortdir_ascending;
|
||||
gboolean ascending_flag, descending_flag;
|
||||
};
|
||||
typedef struct _MuConfigOptions MuConfigOptions;
|
||||
|
||||
|
|
25
src/mu.c
25
src/mu.c
|
@ -17,6 +17,8 @@
|
|||
**
|
||||
*/
|
||||
|
||||
#include <config.h>
|
||||
|
||||
#include <glib.h>
|
||||
#include <glib-object.h>
|
||||
#include <string.h>
|
||||
|
@ -84,6 +86,23 @@ show_help (const char* cmd)
|
|||
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
|
||||
show_usage (gboolean noerror)
|
||||
{
|
||||
|
@ -99,7 +118,6 @@ show_usage (gboolean noerror)
|
|||
|
||||
return noerror ? 0 : 1;
|
||||
}
|
||||
|
||||
int
|
||||
main (int argc, char *argv[])
|
||||
{
|
||||
|
@ -128,10 +146,15 @@ main (int argc, char *argv[])
|
|||
g_error_free (error);
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (config.version)
|
||||
return show_version ();
|
||||
|
||||
if (argc < 2)
|
||||
return show_usage (FALSE);
|
||||
|
||||
|
||||
|
||||
cmd = parse_cmd (argv[1]);
|
||||
if (cmd == MU_CMD_UNKNOWN)
|
||||
return show_usage (FALSE);
|
||||
|
|
Loading…
Reference in New Issue