mirror of https://github.com/djcb/mu.git
mu: improve help text generation
This commit is contained in:
parent
80f947024a
commit
169921fd21
|
@ -55,7 +55,7 @@ mu_SOURCES= \
|
||||||
BUILT_SOURCES= \
|
BUILT_SOURCES= \
|
||||||
mu-help-strings.h
|
mu-help-strings.h
|
||||||
|
|
||||||
mu-help-strings.h: mu-help-strings.txt mu-help-strings.awk
|
mu-help-strings.inc: mu-help-strings.txt mu-help-strings.awk
|
||||||
$(AM_V_GEN) $(AWK) -f ${top_srcdir}/mu/mu-help-strings.awk < $< > $@
|
$(AM_V_GEN) $(AWK) -f ${top_srcdir}/mu/mu-help-strings.awk < $< > $@
|
||||||
|
|
||||||
mu_LDADD= \
|
mu_LDADD= \
|
||||||
|
|
|
@ -17,7 +17,7 @@
|
||||||
awk_script=join_paths(meson.current_source_dir(), 'mu-help-strings.awk')
|
awk_script=join_paths(meson.current_source_dir(), 'mu-help-strings.awk')
|
||||||
mu_help_strings_h=custom_target('mu_help',
|
mu_help_strings_h=custom_target('mu_help',
|
||||||
input: 'mu-help-strings.txt',
|
input: 'mu-help-strings.txt',
|
||||||
output: 'mu-help-strings.h',
|
output: 'mu-help-strings.inc',
|
||||||
command: [awk, '-f', awk_script, '@INPUT@'],
|
command: [awk, '-f', awk_script, '@INPUT@'],
|
||||||
capture: true)
|
capture: true)
|
||||||
mu = executable(
|
mu = executable(
|
||||||
|
|
589
mu/mu-config.cc
589
mu/mu-config.cc
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
** Copyright (C) 2008-2020 Dirk-Jan C. Binnema <djcb@djcbsoftware.nl>
|
** Copyright (C) 2008-2022 Dirk-Jan C. Binnema <djcb@djcbsoftware.nl>
|
||||||
**
|
**
|
||||||
** This program is free software; you can redistribute it and/or modify it
|
** 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
|
** under the terms of the GNU General Public License as published by the
|
||||||
|
@ -62,14 +62,14 @@ get_output_format(const char* formatstr)
|
||||||
return MU_CONFIG_FORMAT_UNKNOWN;
|
return MU_CONFIG_FORMAT_UNKNOWN;
|
||||||
}
|
}
|
||||||
|
|
||||||
#define expand_dir(D) \
|
#define expand_dir(D) \
|
||||||
if ((D)) { \
|
if ((D)) { \
|
||||||
char* exp; \
|
char* exp; \
|
||||||
exp = mu_util_dir_expand((D)); \
|
exp = mu_util_dir_expand((D)); \
|
||||||
if (exp) { \
|
if (exp) { \
|
||||||
g_free((D)); \
|
g_free((D)); \
|
||||||
(D) = exp; \
|
(D) = exp; \
|
||||||
} \
|
} \
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -93,64 +93,25 @@ static GOptionGroup*
|
||||||
config_options_group_mu()
|
config_options_group_mu()
|
||||||
{
|
{
|
||||||
GOptionGroup* og;
|
GOptionGroup* og;
|
||||||
GOptionEntry entries[] = {{"debug",
|
GOptionEntry entries[] = {
|
||||||
'd',
|
{"debug", 'd', 0, G_OPTION_ARG_NONE, &MU_CONFIG.debug,
|
||||||
0,
|
"print debug output to standard error (false)", NULL},
|
||||||
G_OPTION_ARG_NONE,
|
{"quiet", 'q', 0, G_OPTION_ARG_NONE, &MU_CONFIG.quiet,
|
||||||
&MU_CONFIG.debug,
|
"don't give any progress information (false)", NULL},
|
||||||
"print debug output to standard error (false)",
|
{"version", 'V', 0, G_OPTION_ARG_NONE, &MU_CONFIG.version,
|
||||||
NULL},
|
"display version and copyright information (false)", NULL},
|
||||||
{"quiet",
|
{"muhome", 0, 0, G_OPTION_ARG_FILENAME, &MU_CONFIG.muhome,
|
||||||
'q',
|
"specify an alternative mu directory", "<dir>"},
|
||||||
0,
|
{"log-stderr", 0, 0, G_OPTION_ARG_NONE, &MU_CONFIG.log_stderr,
|
||||||
G_OPTION_ARG_NONE,
|
"log to standard error (false)", NULL},
|
||||||
&MU_CONFIG.quiet,
|
{"nocolor", 0, 0, G_OPTION_ARG_NONE, &MU_CONFIG.nocolor,
|
||||||
"don't give any progress information (false)",
|
"don't use ANSI-colors in output (false)", NULL},
|
||||||
NULL},
|
{"verbose", 'v', 0, G_OPTION_ARG_NONE, &MU_CONFIG.verbose,
|
||||||
{"version",
|
"verbose output (false)", NULL},
|
||||||
'V',
|
|
||||||
0,
|
|
||||||
G_OPTION_ARG_NONE,
|
|
||||||
&MU_CONFIG.version,
|
|
||||||
"display version and copyright information (false)",
|
|
||||||
NULL},
|
|
||||||
{"muhome",
|
|
||||||
0,
|
|
||||||
0,
|
|
||||||
G_OPTION_ARG_FILENAME,
|
|
||||||
&MU_CONFIG.muhome,
|
|
||||||
"specify an alternative mu directory",
|
|
||||||
"<dir>"},
|
|
||||||
{"log-stderr",
|
|
||||||
0,
|
|
||||||
0,
|
|
||||||
G_OPTION_ARG_NONE,
|
|
||||||
&MU_CONFIG.log_stderr,
|
|
||||||
"log to standard error (false)",
|
|
||||||
NULL},
|
|
||||||
{"nocolor",
|
|
||||||
0,
|
|
||||||
0,
|
|
||||||
G_OPTION_ARG_NONE,
|
|
||||||
&MU_CONFIG.nocolor,
|
|
||||||
"don't use ANSI-colors in output (false)",
|
|
||||||
NULL},
|
|
||||||
{"verbose",
|
|
||||||
'v',
|
|
||||||
0,
|
|
||||||
G_OPTION_ARG_NONE,
|
|
||||||
&MU_CONFIG.verbose,
|
|
||||||
"verbose output (false)",
|
|
||||||
NULL},
|
|
||||||
|
|
||||||
{G_OPTION_REMAINING,
|
{G_OPTION_REMAINING, 0, 0, G_OPTION_ARG_STRING_ARRAY, &MU_CONFIG.params,
|
||||||
0,
|
"parameters", NULL},
|
||||||
0,
|
{NULL, 0, 0, (GOptionArg)0, NULL, NULL, NULL}};
|
||||||
G_OPTION_ARG_STRING_ARRAY,
|
|
||||||
&MU_CONFIG.params,
|
|
||||||
"parameters",
|
|
||||||
NULL},
|
|
||||||
{NULL, 0, 0, (GOptionArg)0, NULL, NULL, NULL}};
|
|
||||||
|
|
||||||
og = g_option_group_new("mu", "general mu options", "", NULL, NULL);
|
og = g_option_group_new("mu", "general mu options", "", NULL, NULL);
|
||||||
g_option_group_add_entries(og, entries);
|
g_option_group_add_entries(og, entries);
|
||||||
|
@ -171,35 +132,16 @@ static GOptionGroup*
|
||||||
config_options_group_init()
|
config_options_group_init()
|
||||||
{
|
{
|
||||||
GOptionGroup* og;
|
GOptionGroup* og;
|
||||||
GOptionEntry entries[] = {{"maildir",
|
GOptionEntry entries[] = {
|
||||||
'm',
|
{"maildir", 'm', 0, G_OPTION_ARG_FILENAME, &MU_CONFIG.maildir,
|
||||||
0,
|
"top of the maildir", "<maildir>"},
|
||||||
G_OPTION_ARG_FILENAME,
|
{"my-address", 0, 0, G_OPTION_ARG_STRING_ARRAY, &MU_CONFIG.my_addresses,
|
||||||
&MU_CONFIG.maildir,
|
"my e-mail address; can be used multiple times", "<address>"},
|
||||||
"top of the maildir",
|
{"max-message-size", 0, 0, G_OPTION_ARG_INT, &MU_CONFIG.max_msg_size,
|
||||||
"<maildir>"},
|
"Maximum allowed size for messages", "<size-in-bytes>"},
|
||||||
{"my-address",
|
{"batch-size", 0, 0, G_OPTION_ARG_INT, &MU_CONFIG.batch_size,
|
||||||
0,
|
"Number of changes in a database transaction batch", "<number>"},
|
||||||
0,
|
{NULL, 0, 0, G_OPTION_ARG_NONE, NULL, NULL, NULL}};
|
||||||
G_OPTION_ARG_STRING_ARRAY,
|
|
||||||
&MU_CONFIG.my_addresses,
|
|
||||||
"my e-mail address; can be used multiple times",
|
|
||||||
"<address>"},
|
|
||||||
{"max-message-size",
|
|
||||||
0,
|
|
||||||
0,
|
|
||||||
G_OPTION_ARG_INT,
|
|
||||||
&MU_CONFIG.max_msg_size,
|
|
||||||
"Maximum allowed size for messages",
|
|
||||||
"<size-in-bytes>"},
|
|
||||||
{"batch-size",
|
|
||||||
0,
|
|
||||||
0,
|
|
||||||
G_OPTION_ARG_INT,
|
|
||||||
&MU_CONFIG.batch_size,
|
|
||||||
"Number of changes in a database transaction batch",
|
|
||||||
"<number>"},
|
|
||||||
{NULL, 0, 0, G_OPTION_ARG_NONE, NULL, NULL, NULL}};
|
|
||||||
|
|
||||||
og = g_option_group_new("init", "Options for the 'init' command", "", NULL, NULL);
|
og = g_option_group_new("init", "Options for the 'init' command", "", NULL, NULL);
|
||||||
g_option_group_add_entries(og, entries);
|
g_option_group_add_entries(og, entries);
|
||||||
|
@ -208,18 +150,19 @@ config_options_group_init()
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
index_post_parse_func(GOptionContext* context, GOptionGroup* group, gpointer data, GError** error)
|
index_post_parse_func(GOptionContext* context, GOptionGroup* group, gpointer data,
|
||||||
|
GError** error)
|
||||||
{
|
{
|
||||||
if (!MU_CONFIG.maildir && !MU_CONFIG.my_addresses)
|
if (!MU_CONFIG.maildir && !MU_CONFIG.my_addresses)
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
|
||||||
g_printerr("%sNOTE%s: as of mu 1.3.8, 'mu index' no longer uses the\n"
|
g_printerr("%sNOTE%s: as of mu 1.3.8, 'mu index' no longer uses the\n"
|
||||||
"--maildir/-m or --my-address options.\n\n",
|
"--maildir/-m or --my-address options.\n\n",
|
||||||
color_maybe(MU_COLOR_RED),
|
color_maybe(MU_COLOR_RED), color_maybe(MU_COLOR_DEFAULT));
|
||||||
color_maybe(MU_COLOR_DEFAULT));
|
|
||||||
g_printerr("Instead, these options should be passed to 'mu init'.\n");
|
g_printerr("Instead, these options should be passed to 'mu init'.\n");
|
||||||
g_printerr("See the mu-init(1) or the mu4e reference manual,\n'Initializing the message "
|
g_printerr(
|
||||||
"store' for details.\n\n");
|
"See the mu-init(1) or the mu4e reference manual,\n'Initializing the message "
|
||||||
|
"store' for details.\n\n");
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
@ -228,39 +171,22 @@ static GOptionGroup*
|
||||||
config_options_group_index()
|
config_options_group_index()
|
||||||
{
|
{
|
||||||
GOptionGroup* og;
|
GOptionGroup* og;
|
||||||
GOptionEntry entries[] = {/* only here so we can tell users they are deprecated */
|
GOptionEntry entries[] = {
|
||||||
{"maildir",
|
/* only here so we can tell users they are deprecated */
|
||||||
'm',
|
{"maildir", 'm', G_OPTION_FLAG_HIDDEN, G_OPTION_ARG_FILENAME,
|
||||||
G_OPTION_FLAG_HIDDEN,
|
&MU_CONFIG.maildir, "top of the maildir", "<maildir>"},
|
||||||
G_OPTION_ARG_FILENAME,
|
{"my-address", 0, G_OPTION_FLAG_HIDDEN, G_OPTION_ARG_STRING_ARRAY,
|
||||||
&MU_CONFIG.maildir,
|
&MU_CONFIG.my_addresses, "my e-mail address; can be used multiple times",
|
||||||
"top of the maildir",
|
"<address>"},
|
||||||
"<maildir>"},
|
|
||||||
{"my-address",
|
|
||||||
0,
|
|
||||||
G_OPTION_FLAG_HIDDEN,
|
|
||||||
G_OPTION_ARG_STRING_ARRAY,
|
|
||||||
&MU_CONFIG.my_addresses,
|
|
||||||
"my e-mail address; can be used multiple times",
|
|
||||||
"<address>"},
|
|
||||||
|
|
||||||
{"lazy-check",
|
{"lazy-check", 0, 0, G_OPTION_ARG_NONE, &MU_CONFIG.lazycheck,
|
||||||
0,
|
"only check dir-timestamps (false)", NULL},
|
||||||
0,
|
{"nocleanup", 0, 0, G_OPTION_ARG_NONE, &MU_CONFIG.nocleanup,
|
||||||
G_OPTION_ARG_NONE,
|
"don't clean up the database after indexing (false)", NULL},
|
||||||
&MU_CONFIG.lazycheck,
|
{NULL, 0, 0, G_OPTION_ARG_NONE, NULL, NULL, NULL}};
|
||||||
"only check dir-timestamps (false)",
|
|
||||||
NULL},
|
|
||||||
{"nocleanup",
|
|
||||||
0,
|
|
||||||
0,
|
|
||||||
G_OPTION_ARG_NONE,
|
|
||||||
&MU_CONFIG.nocleanup,
|
|
||||||
"don't clean up the database after indexing (false)",
|
|
||||||
NULL},
|
|
||||||
{NULL, 0, 0, G_OPTION_ARG_NONE, NULL, NULL, NULL}};
|
|
||||||
|
|
||||||
og = g_option_group_new("index", "Options for the 'index' command", "", NULL, NULL);
|
og = g_option_group_new("index", "Options for the 'index' command", "", NULL,
|
||||||
|
NULL);
|
||||||
g_option_group_add_entries(og, entries);
|
g_option_group_add_entries(og, entries);
|
||||||
g_option_group_set_parse_hooks(og, NULL, (GOptionParseFunc)index_post_parse_func);
|
g_option_group_set_parse_hooks(og, NULL, (GOptionParseFunc)index_post_parse_func);
|
||||||
|
|
||||||
|
@ -290,106 +216,38 @@ static GOptionGroup*
|
||||||
config_options_group_find()
|
config_options_group_find()
|
||||||
{
|
{
|
||||||
GOptionGroup* og;
|
GOptionGroup* og;
|
||||||
GOptionEntry entries[] = {{"fields",
|
GOptionEntry entries[] = {
|
||||||
'f',
|
{"fields", 'f', 0, G_OPTION_ARG_STRING, &MU_CONFIG.fields,
|
||||||
0,
|
"fields to display in the output", "<fields>"},
|
||||||
G_OPTION_ARG_STRING,
|
{"sortfield", 's', 0, G_OPTION_ARG_STRING, &MU_CONFIG.sortfield,
|
||||||
&MU_CONFIG.fields,
|
"field to sort on", "<field>"},
|
||||||
"fields to display in the output",
|
{"maxnum", 'n', 0, G_OPTION_ARG_INT, &MU_CONFIG.maxnum,
|
||||||
"<fields>"},
|
"number of entries to display in the output", "<number>"},
|
||||||
{"sortfield",
|
{"threads", 't', 0, G_OPTION_ARG_NONE, &MU_CONFIG.threads,
|
||||||
's',
|
"show message threads", NULL},
|
||||||
0,
|
{"bookmark", 'b', 0, G_OPTION_ARG_STRING, &MU_CONFIG.bookmark,
|
||||||
G_OPTION_ARG_STRING,
|
"use a bookmarked query", "<bookmark>"},
|
||||||
&MU_CONFIG.sortfield,
|
{"reverse", 'z', 0, G_OPTION_ARG_NONE, &MU_CONFIG.reverse,
|
||||||
"field to sort on",
|
"sort in reverse (descending) order (z -> a)", NULL},
|
||||||
"<field>"},
|
{"skip-dups", 'u', 0, G_OPTION_ARG_NONE, &MU_CONFIG.skip_dups,
|
||||||
{"maxnum",
|
"show only the first of messages duplicates (false)", NULL},
|
||||||
'n',
|
{"include-related", 'r', 0, G_OPTION_ARG_NONE, &MU_CONFIG.include_related,
|
||||||
0,
|
"include related messages in results (false)", NULL},
|
||||||
G_OPTION_ARG_INT,
|
{"linksdir", 0, 0, G_OPTION_ARG_STRING, &MU_CONFIG.linksdir,
|
||||||
&MU_CONFIG.maxnum,
|
"output as symbolic links to a target maildir", "<dir>"},
|
||||||
"number of entries to display in the output",
|
{"clearlinks", 0, 0, G_OPTION_ARG_NONE, &MU_CONFIG.clearlinks,
|
||||||
"<number>"},
|
"clear old links before filling a linksdir (false)", NULL},
|
||||||
{"threads",
|
{"format", 'o', 0, G_OPTION_ARG_STRING, &MU_CONFIG.formatstr,
|
||||||
't',
|
"output format ('plain'(*), 'links', 'xml',"
|
||||||
0,
|
"'sexp', 'xquery')",
|
||||||
G_OPTION_ARG_NONE,
|
"<format>"},
|
||||||
&MU_CONFIG.threads,
|
{"summary-len", 0, 0, G_OPTION_ARG_INT, &MU_CONFIG.summary_len,
|
||||||
"show message threads",
|
"use up to <n> lines for the summary, or 0 for none (0)", "<len>"},
|
||||||
NULL},
|
{"exec", 'e', 0, G_OPTION_ARG_STRING, &MU_CONFIG.exec,
|
||||||
{"bookmark",
|
"execute command on each match message", "<command>"},
|
||||||
'b',
|
{"after", 0, 0, G_OPTION_ARG_INT, &MU_CONFIG.after,
|
||||||
0,
|
"only show messages whose m_time > T (t_time)", "<timestamp>"},
|
||||||
G_OPTION_ARG_STRING,
|
{NULL, 0, 0, G_OPTION_ARG_NONE, NULL, NULL, NULL}};
|
||||||
&MU_CONFIG.bookmark,
|
|
||||||
"use a bookmarked query",
|
|
||||||
"<bookmark>"},
|
|
||||||
{"reverse",
|
|
||||||
'z',
|
|
||||||
0,
|
|
||||||
G_OPTION_ARG_NONE,
|
|
||||||
&MU_CONFIG.reverse,
|
|
||||||
"sort in reverse (descending) order (z -> a)",
|
|
||||||
NULL},
|
|
||||||
{"skip-dups",
|
|
||||||
'u',
|
|
||||||
0,
|
|
||||||
G_OPTION_ARG_NONE,
|
|
||||||
&MU_CONFIG.skip_dups,
|
|
||||||
"show only the first of messages duplicates (false)",
|
|
||||||
NULL},
|
|
||||||
{"include-related",
|
|
||||||
'r',
|
|
||||||
0,
|
|
||||||
G_OPTION_ARG_NONE,
|
|
||||||
&MU_CONFIG.include_related,
|
|
||||||
"include related messages in results (false)",
|
|
||||||
NULL},
|
|
||||||
{"linksdir",
|
|
||||||
0,
|
|
||||||
0,
|
|
||||||
G_OPTION_ARG_STRING,
|
|
||||||
&MU_CONFIG.linksdir,
|
|
||||||
"output as symbolic links to a target maildir",
|
|
||||||
"<dir>"},
|
|
||||||
{"clearlinks",
|
|
||||||
0,
|
|
||||||
0,
|
|
||||||
G_OPTION_ARG_NONE,
|
|
||||||
&MU_CONFIG.clearlinks,
|
|
||||||
"clear old links before filling a linksdir (false)",
|
|
||||||
NULL},
|
|
||||||
{"format",
|
|
||||||
'o',
|
|
||||||
0,
|
|
||||||
G_OPTION_ARG_STRING,
|
|
||||||
&MU_CONFIG.formatstr,
|
|
||||||
"output format ('plain'(*), 'links', 'xml',"
|
|
||||||
"'sexp', 'xquery')",
|
|
||||||
"<format>"},
|
|
||||||
{"summary-len",
|
|
||||||
0,
|
|
||||||
0,
|
|
||||||
G_OPTION_ARG_INT,
|
|
||||||
&MU_CONFIG.summary_len,
|
|
||||||
"use up to <n> lines for the summary, or 0 for none (0)",
|
|
||||||
"<len>"},
|
|
||||||
{"exec",
|
|
||||||
'e',
|
|
||||||
0,
|
|
||||||
G_OPTION_ARG_STRING,
|
|
||||||
&MU_CONFIG.exec,
|
|
||||||
"execute command on each match message",
|
|
||||||
"<command>"},
|
|
||||||
{"after",
|
|
||||||
0,
|
|
||||||
0,
|
|
||||||
G_OPTION_ARG_INT,
|
|
||||||
&MU_CONFIG.after,
|
|
||||||
"only show messages whose m_time > T (t_time)",
|
|
||||||
"<timestamp>"},
|
|
||||||
{NULL, 0, 0, G_OPTION_ARG_NONE, NULL, NULL, NULL}};
|
|
||||||
|
|
||||||
og = g_option_group_new("find", "Options for the 'find' command", "", NULL, NULL);
|
og = g_option_group_new("find", "Options for the 'find' command", "", NULL, NULL);
|
||||||
g_option_group_add_entries(og, entries);
|
g_option_group_add_entries(og, entries);
|
||||||
|
@ -401,11 +259,7 @@ static GOptionGroup*
|
||||||
config_options_group_mkdir()
|
config_options_group_mkdir()
|
||||||
{
|
{
|
||||||
GOptionGroup* og;
|
GOptionGroup* og;
|
||||||
GOptionEntry entries[] = {{"mode",
|
GOptionEntry entries[] = {{"mode", 0, 0, G_OPTION_ARG_INT, &MU_CONFIG.dirmode,
|
||||||
0,
|
|
||||||
0,
|
|
||||||
G_OPTION_ARG_INT,
|
|
||||||
&MU_CONFIG.dirmode,
|
|
||||||
"set the mode (as in chmod), in octal notation",
|
"set the mode (as in chmod), in octal notation",
|
||||||
"<mode>"},
|
"<mode>"},
|
||||||
{NULL, 0, 0, G_OPTION_ARG_NONE, NULL, NULL, NULL}};
|
{NULL, 0, 0, G_OPTION_ARG_NONE, NULL, NULL, NULL}};
|
||||||
|
@ -413,7 +267,8 @@ config_options_group_mkdir()
|
||||||
/* set dirmode before, because '0000' is a valid mode */
|
/* set dirmode before, because '0000' is a valid mode */
|
||||||
MU_CONFIG.dirmode = 0755;
|
MU_CONFIG.dirmode = 0755;
|
||||||
|
|
||||||
og = g_option_group_new("mkdir", "Options for the 'mkdir' command", "", NULL, NULL);
|
og = g_option_group_new("mkdir", "Options for the 'mkdir' command", "", NULL,
|
||||||
|
NULL);
|
||||||
g_option_group_add_entries(og, entries);
|
g_option_group_add_entries(og, entries);
|
||||||
|
|
||||||
return og;
|
return og;
|
||||||
|
@ -432,31 +287,19 @@ static GOptionGroup*
|
||||||
config_options_group_cfind()
|
config_options_group_cfind()
|
||||||
{
|
{
|
||||||
GOptionGroup* og;
|
GOptionGroup* og;
|
||||||
GOptionEntry entries[] = {{"format",
|
GOptionEntry entries[] = {
|
||||||
'o',
|
{"format", 'o', 0, G_OPTION_ARG_STRING, &MU_CONFIG.formatstr,
|
||||||
0,
|
"output format (plain(*), mutt-alias, mutt-ab, wl, "
|
||||||
G_OPTION_ARG_STRING,
|
"org-contact, bbdb, csv)",
|
||||||
&MU_CONFIG.formatstr,
|
"<format>"},
|
||||||
"output format (plain(*), mutt-alias, mutt-ab, wl, "
|
{"personal", 0, 0, G_OPTION_ARG_NONE, &MU_CONFIG.personal,
|
||||||
"org-contact, bbdb, csv)",
|
"whether to only get 'personal' contacts", NULL},
|
||||||
"<format>"},
|
{"after", 0, 0, G_OPTION_ARG_INT, &MU_CONFIG.after,
|
||||||
{"personal",
|
"only get addresses last seen after T", "<timestamp>"},
|
||||||
0,
|
{NULL, 0, 0, G_OPTION_ARG_NONE, NULL, NULL, NULL}};
|
||||||
0,
|
|
||||||
G_OPTION_ARG_NONE,
|
|
||||||
&MU_CONFIG.personal,
|
|
||||||
"whether to only get 'personal' contacts",
|
|
||||||
NULL},
|
|
||||||
{"after",
|
|
||||||
0,
|
|
||||||
0,
|
|
||||||
G_OPTION_ARG_INT,
|
|
||||||
&MU_CONFIG.after,
|
|
||||||
"only get addresses last seen after T",
|
|
||||||
"<timestamp>"},
|
|
||||||
{NULL, 0, 0, G_OPTION_ARG_NONE, NULL, NULL, NULL}};
|
|
||||||
|
|
||||||
og = g_option_group_new("cfind", "Options for the 'cfind' command", "", NULL, NULL);
|
og = g_option_group_new("cfind", "Options for the 'cfind' command", "", NULL,
|
||||||
|
NULL);
|
||||||
g_option_group_add_entries(og, entries);
|
g_option_group_add_entries(og, entries);
|
||||||
|
|
||||||
return og;
|
return og;
|
||||||
|
@ -466,16 +309,12 @@ static GOptionGroup*
|
||||||
config_options_group_script()
|
config_options_group_script()
|
||||||
{
|
{
|
||||||
GOptionGroup* og;
|
GOptionGroup* og;
|
||||||
GOptionEntry entries[] = {{G_OPTION_REMAINING,
|
GOptionEntry entries[] = {{G_OPTION_REMAINING, 0, 0, G_OPTION_ARG_STRING_ARRAY,
|
||||||
0,
|
&MU_CONFIG.params, "script parameters", NULL},
|
||||||
0,
|
|
||||||
G_OPTION_ARG_STRING_ARRAY,
|
|
||||||
&MU_CONFIG.params,
|
|
||||||
"script parameters",
|
|
||||||
NULL},
|
|
||||||
{NULL, 0, 0, G_OPTION_ARG_NONE, NULL, NULL, NULL}};
|
{NULL, 0, 0, G_OPTION_ARG_NONE, NULL, NULL, NULL}};
|
||||||
|
|
||||||
og = g_option_group_new("script", "Options for the 'script' command", "", NULL, NULL);
|
og = g_option_group_new("script", "Options for the 'script' command", "", NULL,
|
||||||
|
NULL);
|
||||||
|
|
||||||
g_option_group_add_entries(og, entries);
|
g_option_group_add_entries(og, entries);
|
||||||
|
|
||||||
|
@ -495,28 +334,14 @@ set_group_view_defaults()
|
||||||
static GOptionEntry*
|
static GOptionEntry*
|
||||||
crypto_option_entries()
|
crypto_option_entries()
|
||||||
{
|
{
|
||||||
static GOptionEntry entries[] = {{"auto-retrieve",
|
static GOptionEntry entries[] = {
|
||||||
'r',
|
{"auto-retrieve", 'r', 0, G_OPTION_ARG_NONE, &MU_CONFIG.auto_retrieve,
|
||||||
0,
|
"attempt to retrieve keys online (false)", NULL},
|
||||||
G_OPTION_ARG_NONE,
|
{"use-agent", 'a', 0, G_OPTION_ARG_NONE, &MU_CONFIG.use_agent,
|
||||||
&MU_CONFIG.auto_retrieve,
|
"attempt to use the GPG agent (false)", NULL},
|
||||||
"attempt to retrieve keys online (false)",
|
{"decrypt", 0, 0, G_OPTION_ARG_NONE, &MU_CONFIG.decrypt,
|
||||||
NULL},
|
"attempt to decrypt the message", NULL},
|
||||||
{"use-agent",
|
{NULL, 0, 0, G_OPTION_ARG_NONE, NULL, NULL, NULL}};
|
||||||
'a',
|
|
||||||
0,
|
|
||||||
G_OPTION_ARG_NONE,
|
|
||||||
&MU_CONFIG.use_agent,
|
|
||||||
"attempt to use the GPG agent (false)",
|
|
||||||
NULL},
|
|
||||||
{"decrypt",
|
|
||||||
0,
|
|
||||||
0,
|
|
||||||
G_OPTION_ARG_NONE,
|
|
||||||
&MU_CONFIG.decrypt,
|
|
||||||
"attempt to decrypt the message",
|
|
||||||
NULL},
|
|
||||||
{NULL, 0, 0, G_OPTION_ARG_NONE, NULL, NULL, NULL}};
|
|
||||||
|
|
||||||
return entries;
|
return entries;
|
||||||
}
|
}
|
||||||
|
@ -525,28 +350,14 @@ static GOptionGroup*
|
||||||
config_options_group_view()
|
config_options_group_view()
|
||||||
{
|
{
|
||||||
GOptionGroup* og;
|
GOptionGroup* og;
|
||||||
GOptionEntry entries[] = {{"summary-len",
|
GOptionEntry entries[] = {
|
||||||
0,
|
{"summary-len", 0, 0, G_OPTION_ARG_INT, &MU_CONFIG.summary_len,
|
||||||
0,
|
"use up to <n> lines for the summary, or 0 for none (0)", "<len>"},
|
||||||
G_OPTION_ARG_INT,
|
{"terminate", 0, 0, G_OPTION_ARG_NONE, &MU_CONFIG.terminator,
|
||||||
&MU_CONFIG.summary_len,
|
"terminate messages with ascii-0x07 (\\f, form-feed)", NULL},
|
||||||
"use up to <n> lines for the summary, or 0 for none (0)",
|
{"format", 'o', 0, G_OPTION_ARG_STRING, &MU_CONFIG.formatstr,
|
||||||
"<len>"},
|
"output format ('plain'(*), 'sexp')", "<format>"},
|
||||||
{"terminate",
|
{NULL, 0, 0, G_OPTION_ARG_NONE, NULL, NULL, NULL}};
|
||||||
0,
|
|
||||||
0,
|
|
||||||
G_OPTION_ARG_NONE,
|
|
||||||
&MU_CONFIG.terminator,
|
|
||||||
"terminate messages with ascii-0x07 (\\f, form-feed)",
|
|
||||||
NULL},
|
|
||||||
{"format",
|
|
||||||
'o',
|
|
||||||
0,
|
|
||||||
G_OPTION_ARG_STRING,
|
|
||||||
&MU_CONFIG.formatstr,
|
|
||||||
"output format ('plain'(*), 'sexp')",
|
|
||||||
"<format>"},
|
|
||||||
{NULL, 0, 0, G_OPTION_ARG_NONE, NULL, NULL, NULL}};
|
|
||||||
|
|
||||||
og = g_option_group_new("view", "Options for the 'view' command", "", NULL, NULL);
|
og = g_option_group_new("view", "Options for the 'view' command", "", NULL, NULL);
|
||||||
|
|
||||||
|
@ -569,50 +380,22 @@ static GOptionGroup*
|
||||||
config_options_group_extract()
|
config_options_group_extract()
|
||||||
{
|
{
|
||||||
GOptionGroup* og;
|
GOptionGroup* og;
|
||||||
GOptionEntry entries[] = {{"save-attachments",
|
GOptionEntry entries[] = {
|
||||||
'a',
|
{"save-attachments", 'a', 0, G_OPTION_ARG_NONE, &MU_CONFIG.save_attachments,
|
||||||
0,
|
"save all attachments (false)", NULL},
|
||||||
G_OPTION_ARG_NONE,
|
{"save-all", 0, 0, G_OPTION_ARG_NONE, &MU_CONFIG.save_all,
|
||||||
&MU_CONFIG.save_attachments,
|
"save all parts (incl. non-attachments) (false)", NULL},
|
||||||
"save all attachments (false)",
|
{"parts", 0, 0, G_OPTION_ARG_STRING, &MU_CONFIG.parts,
|
||||||
NULL},
|
"save specific parts (comma-separated list)", "<parts>"},
|
||||||
{"save-all",
|
{"target-dir", 0, 0, G_OPTION_ARG_FILENAME, &MU_CONFIG.targetdir,
|
||||||
0,
|
"target directory for saving", "<dir>"},
|
||||||
0,
|
{"overwrite", 0, 0, G_OPTION_ARG_NONE, &MU_CONFIG.overwrite,
|
||||||
G_OPTION_ARG_NONE,
|
"overwrite existing files (false)", NULL},
|
||||||
&MU_CONFIG.save_all,
|
{"play", 0, 0, G_OPTION_ARG_NONE, &MU_CONFIG.play,
|
||||||
"save all parts (incl. non-attachments) (false)",
|
"try to 'play' (open) the extracted parts", NULL},
|
||||||
NULL},
|
{NULL, 0, 0, G_OPTION_ARG_NONE, NULL, NULL, NULL}};
|
||||||
{"parts",
|
og = g_option_group_new("extract", "Options for the 'extract' command", "", NULL,
|
||||||
0,
|
NULL);
|
||||||
0,
|
|
||||||
G_OPTION_ARG_STRING,
|
|
||||||
&MU_CONFIG.parts,
|
|
||||||
"save specific parts (comma-separated list)",
|
|
||||||
"<parts>"},
|
|
||||||
{"target-dir",
|
|
||||||
0,
|
|
||||||
0,
|
|
||||||
G_OPTION_ARG_FILENAME,
|
|
||||||
&MU_CONFIG.targetdir,
|
|
||||||
"target directory for saving",
|
|
||||||
"<dir>"},
|
|
||||||
{"overwrite",
|
|
||||||
0,
|
|
||||||
0,
|
|
||||||
G_OPTION_ARG_NONE,
|
|
||||||
&MU_CONFIG.overwrite,
|
|
||||||
"overwrite existing files (false)",
|
|
||||||
NULL},
|
|
||||||
{"play",
|
|
||||||
0,
|
|
||||||
0,
|
|
||||||
G_OPTION_ARG_NONE,
|
|
||||||
&MU_CONFIG.play,
|
|
||||||
"try to 'play' (open) the extracted parts",
|
|
||||||
NULL},
|
|
||||||
{NULL, 0, 0, G_OPTION_ARG_NONE, NULL, NULL, NULL}};
|
|
||||||
og = g_option_group_new("extract", "Options for the 'extract' command", "", NULL, NULL);
|
|
||||||
g_option_group_add_entries(og, entries);
|
g_option_group_add_entries(og, entries);
|
||||||
g_option_group_add_entries(og, crypto_option_entries());
|
g_option_group_add_entries(og, crypto_option_entries());
|
||||||
|
|
||||||
|
@ -623,7 +406,8 @@ static GOptionGroup*
|
||||||
config_options_group_verify()
|
config_options_group_verify()
|
||||||
{
|
{
|
||||||
GOptionGroup* og;
|
GOptionGroup* og;
|
||||||
og = g_option_group_new("verify", "Options for the 'verify' command", "", NULL, NULL);
|
og = g_option_group_new("verify", "Options for the 'verify' command", "", NULL,
|
||||||
|
NULL);
|
||||||
g_option_group_add_entries(og, crypto_option_entries());
|
g_option_group_add_entries(og, crypto_option_entries());
|
||||||
|
|
||||||
return og;
|
return og;
|
||||||
|
@ -633,23 +417,15 @@ static GOptionGroup*
|
||||||
config_options_group_server()
|
config_options_group_server()
|
||||||
{
|
{
|
||||||
GOptionGroup* og;
|
GOptionGroup* og;
|
||||||
GOptionEntry entries[] = {{"commands",
|
GOptionEntry entries[] = {
|
||||||
0,
|
{"commands", 0, 0, G_OPTION_ARG_NONE, &MU_CONFIG.commands,
|
||||||
0,
|
"list the available command and their parameters, then exit", NULL},
|
||||||
G_OPTION_ARG_NONE,
|
{"eval", 'e', G_OPTION_FLAG_HIDDEN, G_OPTION_ARG_STRING, &MU_CONFIG.eval,
|
||||||
&MU_CONFIG.commands,
|
"expression to evaluate", "<expr>"},
|
||||||
"list the available command and their parameters, then exit",
|
{NULL, 0, 0, G_OPTION_ARG_NONE, NULL, NULL, NULL}};
|
||||||
NULL},
|
|
||||||
{"eval",
|
|
||||||
'e',
|
|
||||||
G_OPTION_FLAG_HIDDEN,
|
|
||||||
G_OPTION_ARG_STRING,
|
|
||||||
&MU_CONFIG.eval,
|
|
||||||
"expression to evaluate",
|
|
||||||
"<expr>"},
|
|
||||||
{NULL, 0, 0, G_OPTION_ARG_NONE, NULL, NULL, NULL}};
|
|
||||||
|
|
||||||
og = g_option_group_new("server", "Options for the 'server' command", "", NULL, NULL);
|
og = g_option_group_new("server", "Options for the 'server' command", "", NULL,
|
||||||
|
NULL);
|
||||||
g_option_group_add_entries(og, entries);
|
g_option_group_add_entries(og, entries);
|
||||||
|
|
||||||
return og;
|
return og;
|
||||||
|
@ -662,20 +438,14 @@ cmd_from_string(const char* str)
|
||||||
struct {
|
struct {
|
||||||
const gchar* name;
|
const gchar* name;
|
||||||
MuConfigCmd cmd;
|
MuConfigCmd cmd;
|
||||||
} cmd_map[] = {{"add", MU_CONFIG_CMD_ADD},
|
} cmd_map[] = {
|
||||||
{"cfind", MU_CONFIG_CMD_CFIND},
|
{"add", MU_CONFIG_CMD_ADD}, {"cfind", MU_CONFIG_CMD_CFIND},
|
||||||
{"extract", MU_CONFIG_CMD_EXTRACT},
|
{"extract", MU_CONFIG_CMD_EXTRACT}, {"find", MU_CONFIG_CMD_FIND},
|
||||||
{"find", MU_CONFIG_CMD_FIND},
|
{"help", MU_CONFIG_CMD_HELP}, {"index", MU_CONFIG_CMD_INDEX},
|
||||||
{"help", MU_CONFIG_CMD_HELP},
|
{"info", MU_CONFIG_CMD_INFO}, {"init", MU_CONFIG_CMD_INIT},
|
||||||
{"index", MU_CONFIG_CMD_INDEX},
|
{"mkdir", MU_CONFIG_CMD_MKDIR}, {"remove", MU_CONFIG_CMD_REMOVE},
|
||||||
{"info", MU_CONFIG_CMD_INFO},
|
{"script", MU_CONFIG_CMD_SCRIPT}, {"server", MU_CONFIG_CMD_SERVER},
|
||||||
{"init", MU_CONFIG_CMD_INIT},
|
{"verify", MU_CONFIG_CMD_VERIFY}, {"view", MU_CONFIG_CMD_VIEW}};
|
||||||
{"mkdir", MU_CONFIG_CMD_MKDIR},
|
|
||||||
{"remove", MU_CONFIG_CMD_REMOVE},
|
|
||||||
{"script", MU_CONFIG_CMD_SCRIPT},
|
|
||||||
{"server", MU_CONFIG_CMD_SERVER},
|
|
||||||
{"verify", MU_CONFIG_CMD_VERIFY},
|
|
||||||
{"view", MU_CONFIG_CMD_VIEW}};
|
|
||||||
|
|
||||||
if (!str)
|
if (!str)
|
||||||
return MU_CONFIG_CMD_UNKNOWN;
|
return MU_CONFIG_CMD_UNKNOWN;
|
||||||
|
@ -712,16 +482,15 @@ parse_cmd(int* argcp, char*** argvp, GError** err)
|
||||||
|
|
||||||
#ifndef BUILD_GUILE
|
#ifndef BUILD_GUILE
|
||||||
if (MU_CONFIG.cmd == MU_CONFIG_CMD_SCRIPT) {
|
if (MU_CONFIG.cmd == MU_CONFIG_CMD_SCRIPT) {
|
||||||
mu_util_g_set_error(err, MU_ERROR_IN_PARAMETERS, "command 'script' not supported");
|
mu_util_g_set_error(err, MU_ERROR_IN_PARAMETERS,
|
||||||
|
"command 'script' not supported");
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
#endif /*!BUILD_GUILE*/
|
#endif /*!BUILD_GUILE*/
|
||||||
|
|
||||||
if (MU_CONFIG.cmdstr && MU_CONFIG.cmdstr[0] != '-' &&
|
if (MU_CONFIG.cmdstr && MU_CONFIG.cmdstr[0] != '-' &&
|
||||||
MU_CONFIG.cmd == MU_CONFIG_CMD_UNKNOWN) {
|
MU_CONFIG.cmd == MU_CONFIG_CMD_UNKNOWN) {
|
||||||
mu_util_g_set_error(err,
|
mu_util_g_set_error(err, MU_ERROR_IN_PARAMETERS, "unknown command '%s'",
|
||||||
MU_ERROR_IN_PARAMETERS,
|
|
||||||
"unknown command '%s'",
|
|
||||||
MU_CONFIG.cmdstr);
|
MU_CONFIG.cmdstr);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
@ -757,30 +526,32 @@ massage_help(const char* help)
|
||||||
GRegex* rx;
|
GRegex* rx;
|
||||||
char* str;
|
char* str;
|
||||||
|
|
||||||
rx = g_regex_new("^Usage:.*\n.*\n", (GRegexCompileFlags)0, G_REGEX_MATCH_NEWLINE_ANY, NULL);
|
rx = g_regex_new("^Usage:.*\n.*\n", (GRegexCompileFlags)0,
|
||||||
|
G_REGEX_MATCH_NEWLINE_ANY, NULL);
|
||||||
str = g_regex_replace(rx, help, -1, 0, "", G_REGEX_MATCH_NEWLINE_ANY, NULL);
|
str = g_regex_replace(rx, help, -1, 0, "", G_REGEX_MATCH_NEWLINE_ANY, NULL);
|
||||||
g_regex_unref(rx);
|
g_regex_unref(rx);
|
||||||
return str;
|
return str;
|
||||||
}
|
}
|
||||||
|
|
||||||
static const gchar*
|
static const char*
|
||||||
get_help_string(MuConfigCmd cmd, gboolean long_help)
|
get_help_string(MuConfigCmd cmd, bool long_help)
|
||||||
{
|
{
|
||||||
unsigned u;
|
struct Help {
|
||||||
|
MuConfigCmd cmd;
|
||||||
|
const char* usage;
|
||||||
|
const char* long_help;
|
||||||
|
};
|
||||||
|
constexpr std::array all_help = {
|
||||||
|
#include "mu-help-strings.inc"
|
||||||
|
};
|
||||||
|
|
||||||
/* this include gets us MU_HELP_STRINGS */
|
const auto help_it = std::find_if(all_help.begin(), all_help.end(),
|
||||||
#include "mu-help-strings.h"
|
[&](auto&& info) { return info.cmd == cmd; });
|
||||||
|
if (help_it == all_help.end()) {
|
||||||
for (u = 0; u != G_N_ELEMENTS(MU_HELP_STRINGS); ++u)
|
g_critical("cannot find info for %u", cmd);
|
||||||
if (cmd == MU_HELP_STRINGS[u].cmd) {
|
return "";
|
||||||
if (long_help)
|
} else
|
||||||
return MU_HELP_STRINGS[u].long_help;
|
return long_help ? help_it->long_help : help_it->usage;
|
||||||
else
|
|
||||||
return MU_HELP_STRINGS[u].usage;
|
|
||||||
}
|
|
||||||
|
|
||||||
g_return_val_if_reached("");
|
|
||||||
return "";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
## Copyright (C) 2012 Dirk-Jan C. Binnema <djcb@djcbsoftware.nl>
|
## Copyright (C) 2012-2022 Dirk-Jan C. Binnema <djcb@djcbsoftware.nl>
|
||||||
##
|
##
|
||||||
## This program is free software; you can redistribute it and/or modify
|
## 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
|
## it under the terms of the GNU General Public License as published by
|
||||||
|
@ -20,20 +20,12 @@
|
||||||
BEGIN {
|
BEGIN {
|
||||||
in_def=0;
|
in_def=0;
|
||||||
in_string=0;
|
in_string=0;
|
||||||
# srand();
|
|
||||||
# guard=int(100000*rand());
|
|
||||||
# print "#ifndef __" guard "__"
|
|
||||||
print "/* Do not edit - auto-generated. */"
|
print "/* Do not edit - auto-generated. */"
|
||||||
print "static const struct {"
|
|
||||||
print "\tMuConfigCmd cmd;"
|
|
||||||
print "\tconst char *usage;"
|
|
||||||
print "\tconst char *long_help;"
|
|
||||||
print "} MU_HELP_STRINGS[] = {"
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/^#BEGIN/ {
|
/^#BEGIN/ {
|
||||||
print "\t{ " $2 "," # e.g., MU_CONFIG_CMD_ADD
|
printf "\tHelp {\n\t\t" $2 "," # e.g., MU_CONFIG_CMD_ADD
|
||||||
in_def=1
|
in_def=1
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -51,19 +43,16 @@ BEGIN {
|
||||||
in_string=0;
|
in_string=0;
|
||||||
}
|
}
|
||||||
in_def=0;
|
in_def=0;
|
||||||
print "\n\t},\n"
|
printf "\n\t},\n"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
!/^#/ {
|
!/^#/ {
|
||||||
if (in_string==1) {
|
if (in_string==1) {
|
||||||
printf "\n\t\"" $0 "\\n\""
|
printf "\n\t\t\"" $0 "\\n\""
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
END {
|
END {
|
||||||
print "};"
|
|
||||||
# print "#endif /*" guard "*/"
|
|
||||||
print "/* the end */"
|
print "/* the end */"
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue