mirror of https://github.com/djcb/mu.git
* help: generate help texts from text file / awk
This commit is contained in:
parent
2f7f3a0e57
commit
1c2a87a841
|
@ -40,6 +40,8 @@ AC_PROG_INSTALL
|
||||||
AC_PROG_CXX
|
AC_PROG_CXX
|
||||||
AC_HEADER_STDC
|
AC_HEADER_STDC
|
||||||
|
|
||||||
|
AC_PROG_AWK
|
||||||
|
|
||||||
AC_CHECK_HEADERS([locale.h langinfo.h])
|
AC_CHECK_HEADERS([locale.h langinfo.h])
|
||||||
|
|
||||||
# use the 64-bit versions
|
# use the 64-bit versions
|
||||||
|
|
|
@ -49,6 +49,16 @@ mu_SOURCES= \
|
||||||
mu-cmd.c \
|
mu-cmd.c \
|
||||||
mu-cmd.h
|
mu-cmd.h
|
||||||
|
|
||||||
|
BUILT_SOURCES= \
|
||||||
|
mu-help-strings.h
|
||||||
|
|
||||||
|
mu-help-strings.h: mu-help-strings.txt mu-help-strings.awk
|
||||||
|
$(AWK) -f mu-help-strings.awk < $< > $@
|
||||||
|
|
||||||
mu_LDADD= \
|
mu_LDADD= \
|
||||||
${top_builddir}/lib/libmu.la \
|
${top_builddir}/lib/libmu.la \
|
||||||
$(GLIB_LIBS)
|
$(GLIB_LIBS)
|
||||||
|
|
||||||
|
EXTRA_DIST= \
|
||||||
|
mu-help-strings.awk \
|
||||||
|
mu-help-strings.txt
|
||||||
|
|
|
@ -466,76 +466,20 @@ get_option_group (MuConfigCmd cmd)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
static const gchar*
|
static const gchar*
|
||||||
cmd_help (MuConfigCmd cmd, gboolean long_help)
|
cmd_help (MuConfigCmd cmd, gboolean long_help)
|
||||||
{
|
{
|
||||||
unsigned u;
|
unsigned u;
|
||||||
|
|
||||||
static const struct {
|
/* this include gets us MU_HELP_STRINGS */
|
||||||
MuConfigCmd cmd;
|
#include "mu-help-strings.h"
|
||||||
const char *usage;
|
|
||||||
const char *long_help;
|
|
||||||
} help_strings[] = {
|
|
||||||
{ MU_CONFIG_CMD_ADD,
|
|
||||||
"mu add <file> [<files>]",
|
|
||||||
"mu add is the command to add specific measage files to the\n"
|
|
||||||
"database. Each of the files must be specified with an "
|
|
||||||
"absolute path." },
|
|
||||||
{ MU_CONFIG_CMD_CFIND,
|
|
||||||
"mu cfind [options] [<pattern>]",
|
|
||||||
"mu cfind is the mu command to find contacts in the mu\n"
|
|
||||||
"database and export them for use in other programs." },
|
|
||||||
{ MU_CONFIG_CMD_EXTRACT,
|
|
||||||
"mu extract [options] <file>\n"
|
|
||||||
"mu extract [options] <file> <pattern>",
|
|
||||||
"mu extract is the mu command to display and save message parts "
|
|
||||||
"(attachments)\n, and open them with other tools." },
|
|
||||||
{ MU_CONFIG_CMD_FIND,
|
|
||||||
"mu find [options] <search expression>",
|
|
||||||
"mu find is the mu command for searching e-mail message that were "
|
|
||||||
"stored earlier using mu index(1)." },
|
|
||||||
{ MU_CONFIG_CMD_HELP,
|
|
||||||
"mu help <command>",
|
|
||||||
"mu find is the mu command to get help about <command>." },
|
|
||||||
{ MU_CONFIG_CMD_INDEX,
|
|
||||||
"mu index [options]",
|
|
||||||
"mu index is the mu command for scanning the contents of Maildir "
|
|
||||||
"directories\nand storing the results in a Xapian database.\n\nThe "
|
|
||||||
"data can then be queried using mu-find(1)."},
|
|
||||||
{ MU_CONFIG_CMD_MKDIR,
|
|
||||||
"mu mkdir [options] <dir> [<dirs>]",
|
|
||||||
"mu mkdir is the mu command for creating Maildirs.\nIt does not "
|
|
||||||
"use the mu database. "},
|
|
||||||
{ MU_CONFIG_CMD_REMOVE,
|
|
||||||
"mu remove [options] <file> [<files>]",
|
|
||||||
"mu remove is the mu command to remove messages from the database." },
|
|
||||||
{ MU_CONFIG_CMD_SERVER,
|
|
||||||
"mu server [options]",
|
|
||||||
"mu server starts a simple shell in which one can query and "
|
|
||||||
"manipulate the mu database.\nThe output of the commands is terms "
|
|
||||||
"of Lisp symbolic expressions (s-exps).\nmu server is not meant for "
|
|
||||||
"use by humans; instead, it is designed specifically\nfor the "
|
|
||||||
"mu4e e-mail client." },
|
|
||||||
{ MU_CONFIG_CMD_VERIFY,
|
|
||||||
"mu verify [options] <msgfile>",
|
|
||||||
"mu verify is the mu command for verifying message signatures "
|
|
||||||
"(such as PGP/GPG signatures)\nand displaying information about them."
|
|
||||||
"\n\nThe command works on message files, and does not require "
|
|
||||||
"the message to be indexed in the database."},
|
|
||||||
{ MU_CONFIG_CMD_VIEW,
|
|
||||||
"mu view [options] <file> [<files>]",
|
|
||||||
"mu view is the mu command for displaying e-mail message files. It "
|
|
||||||
"works on message files and does \fInot\fR require the message to be "
|
|
||||||
"indexed in the database."}
|
|
||||||
};
|
|
||||||
|
|
||||||
for (u = 0; u != G_N_ELEMENTS(help_strings); ++u)
|
for (u = 0; u != G_N_ELEMENTS(MU_HELP_STRINGS); ++u)
|
||||||
if (cmd == help_strings[u].cmd) {
|
if (cmd == MU_HELP_STRINGS[u].cmd) {
|
||||||
if (long_help)
|
if (long_help)
|
||||||
return help_strings[u].long_help;
|
return MU_HELP_STRINGS[u].long_help;
|
||||||
else
|
else
|
||||||
return help_strings[u].usage ;
|
return MU_HELP_STRINGS[u].usage ;
|
||||||
}
|
}
|
||||||
|
|
||||||
g_return_val_if_reached ("");
|
g_return_val_if_reached ("");
|
||||||
|
@ -543,7 +487,10 @@ cmd_help (MuConfigCmd cmd, gboolean long_help)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* ugh yuck massaging of the GOption text output */
|
/* ugh yuck massaging the GOption text output; glib prepares some text
|
||||||
|
* which has a 'Usage:' for the 'help' commmand. However, we need the
|
||||||
|
* help for the command we're asking help for. So, we remove the Usage:
|
||||||
|
* from what glib generates. :-( */
|
||||||
static gchar*
|
static gchar*
|
||||||
massage_help (const char *help)
|
massage_help (const char *help)
|
||||||
{
|
{
|
||||||
|
|
|
@ -0,0 +1,69 @@
|
||||||
|
## Copyright (C) 2012 Dirk-Jan C. Binnema <djcb@djcbsoftware.nl>
|
||||||
|
##
|
||||||
|
## 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 of the License, 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.
|
||||||
|
|
||||||
|
|
||||||
|
## convert text blobs statements into c-strings
|
||||||
|
|
||||||
|
BEGIN {
|
||||||
|
in_def=0;
|
||||||
|
in_string=0;
|
||||||
|
# srand();
|
||||||
|
# guard=int(100000*rand());
|
||||||
|
# print "#ifndef __" guard "__"
|
||||||
|
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/ {
|
||||||
|
print "\t{ " $2 "," # e.g., MU_CONFIG_CMD_ADD
|
||||||
|
in_def=1
|
||||||
|
}
|
||||||
|
|
||||||
|
/^#STRING/ {
|
||||||
|
if (in_def== 1) {
|
||||||
|
if (in_string==1) {
|
||||||
|
print ",";
|
||||||
|
}
|
||||||
|
in_string=1
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/^#END/ {
|
||||||
|
if (in_string==1) {
|
||||||
|
in_string=0;
|
||||||
|
}
|
||||||
|
in_def=0;
|
||||||
|
print "\n\t},\n"
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
!/^#/ {
|
||||||
|
if (in_string==1) {
|
||||||
|
printf "\n\t\"" $0 "\\n\""
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
END {
|
||||||
|
print "};"
|
||||||
|
# print "#endif /*" guard "*/"
|
||||||
|
print "/* the end */"
|
||||||
|
}
|
|
@ -0,0 +1,115 @@
|
||||||
|
#-*-mode:org-*-
|
||||||
|
# Copyright (C) 2012 Dirk-Jan C. Binnema <djcb@djcbsoftware.nl>
|
||||||
|
#
|
||||||
|
# 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 of the License, 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.
|
||||||
|
|
||||||
|
|
||||||
|
#BEGIN MU_CONFIG_CMD_ADD
|
||||||
|
#STRING
|
||||||
|
mu add <file> [<files>]
|
||||||
|
#STRING
|
||||||
|
mu add is the command to add specific measage files to the
|
||||||
|
database. Each of the files must be specified with an
|
||||||
|
absolute path
|
||||||
|
#END
|
||||||
|
|
||||||
|
#BEGIN MU_CONFIG_CMD_CFIND
|
||||||
|
#STRING
|
||||||
|
mu cfind [options] [<pattern>]
|
||||||
|
#STRING
|
||||||
|
mu cfind is the mu command to find contacts in the mu database and export them
|
||||||
|
for use in other programs.
|
||||||
|
#END
|
||||||
|
|
||||||
|
#BEGIN MU_CONFIG_CMD_EXTRACT
|
||||||
|
#STRING
|
||||||
|
mu extract [options] <file>
|
||||||
|
#STRING
|
||||||
|
mu extract is the mu command to display and save message parts
|
||||||
|
(attachments), and open them with other tools.
|
||||||
|
#END
|
||||||
|
|
||||||
|
#BEGIN MU_CONFIG_CMD_FIND
|
||||||
|
#STRING
|
||||||
|
mu find [options] <search expression>
|
||||||
|
#STRING
|
||||||
|
mu find is the mu command for searching e-mail message that were
|
||||||
|
stored earlier using mu index(1).
|
||||||
|
#END
|
||||||
|
|
||||||
|
|
||||||
|
#BEGIN MU_CONFIG_CMD_HELP
|
||||||
|
#STRING
|
||||||
|
mu help <command>
|
||||||
|
#STRING
|
||||||
|
mu find is the mu command to get help about <command>.
|
||||||
|
#END
|
||||||
|
|
||||||
|
#BEGIN MU_CONFIG_CMD_INDEX
|
||||||
|
#STRING
|
||||||
|
mu index [options]
|
||||||
|
#STRING
|
||||||
|
mu index is the mu command for scanning the contents of Maildir
|
||||||
|
directories and storing the results in a Xapian database.The
|
||||||
|
data can then be queried using mu-find(1).
|
||||||
|
#END
|
||||||
|
|
||||||
|
#BEGIN MU_CONFIG_CMD_MKDIR
|
||||||
|
#STRING
|
||||||
|
mu mkdir [options] <dir> [<dirs>]
|
||||||
|
#STRING
|
||||||
|
mu mkdir is the mu command for creating Maildirs.It does not
|
||||||
|
use the mu database.
|
||||||
|
#END
|
||||||
|
|
||||||
|
|
||||||
|
#BEGIN MU_CONFIG_CMD_REMOVE
|
||||||
|
#STRING
|
||||||
|
mu remove [options] <file> [<files>]
|
||||||
|
#STRING
|
||||||
|
mu remove is the mu command to remove messages from the database.
|
||||||
|
#END
|
||||||
|
|
||||||
|
|
||||||
|
#BEGIN MU_CONFIG_CMD_SERVER
|
||||||
|
#STRING
|
||||||
|
mu server [options]
|
||||||
|
#STRING
|
||||||
|
mu server starts a simple shell in which one can query and
|
||||||
|
manipulate the mu database.The output of the commands is terms
|
||||||
|
of Lisp symbolic expressions (s-exps).mu server is not meant for
|
||||||
|
use by humans; instead, it is designed specificallyfor the
|
||||||
|
mu4e e-mail client.
|
||||||
|
#END
|
||||||
|
|
||||||
|
|
||||||
|
#BEGIN MU_CONFIG_CMD_VERIFY
|
||||||
|
#STRING
|
||||||
|
mu verify [options] <msgfile>
|
||||||
|
#STRING
|
||||||
|
mu verify is the mu command for verifying message signatures
|
||||||
|
(such as PGP/GPG signatures)and displaying information about them.
|
||||||
|
The command works on message files, and does not require
|
||||||
|
the message to be indexed in the database.
|
||||||
|
#END
|
||||||
|
|
||||||
|
#BEGIN MU_CONFIG_CMD_VIEW
|
||||||
|
#STRING
|
||||||
|
mu view [options] <file> [<files>]
|
||||||
|
#STRING
|
||||||
|
mu view is the mu command for displaying e-mail message files. It
|
||||||
|
works on message files and does not require the message to be
|
||||||
|
indexed in the database.
|
||||||
|
#END
|
Loading…
Reference in New Issue