diff --git a/configure.ac b/configure.ac index 082c140b..624ab36f 100644 --- a/configure.ac +++ b/configure.ac @@ -40,6 +40,8 @@ AC_PROG_INSTALL AC_PROG_CXX AC_HEADER_STDC +AC_PROG_AWK + AC_CHECK_HEADERS([locale.h langinfo.h]) # use the 64-bit versions diff --git a/mu/Makefile.am b/mu/Makefile.am index 475042f0..4cbdf9f7 100644 --- a/mu/Makefile.am +++ b/mu/Makefile.am @@ -49,6 +49,16 @@ mu_SOURCES= \ mu-cmd.c \ 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= \ ${top_builddir}/lib/libmu.la \ $(GLIB_LIBS) + +EXTRA_DIST= \ + mu-help-strings.awk \ + mu-help-strings.txt diff --git a/mu/mu-config.c b/mu/mu-config.c index 15f28ac2..815e1e61 100644 --- a/mu/mu-config.c +++ b/mu/mu-config.c @@ -466,76 +466,20 @@ get_option_group (MuConfigCmd cmd) - static const gchar* cmd_help (MuConfigCmd cmd, gboolean long_help) { unsigned u; - static const struct { - MuConfigCmd cmd; - const char *usage; - const char *long_help; - } help_strings[] = { - { MU_CONFIG_CMD_ADD, - "mu add []", - "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] []", - "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] \n" - "mu extract [options] ", - "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] ", - "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 ", - "mu find is the mu command to get help about ." }, - { 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] []", - "mu mkdir is the mu command for creating Maildirs.\nIt does not " - "use the mu database. "}, - { MU_CONFIG_CMD_REMOVE, - "mu remove [options] []", - "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] ", - "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] []", - "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."} - }; + /* this include gets us MU_HELP_STRINGS */ +#include "mu-help-strings.h" - for (u = 0; u != G_N_ELEMENTS(help_strings); ++u) - if (cmd == help_strings[u].cmd) { + for (u = 0; u != G_N_ELEMENTS(MU_HELP_STRINGS); ++u) + if (cmd == MU_HELP_STRINGS[u].cmd) { if (long_help) - return help_strings[u].long_help; + return MU_HELP_STRINGS[u].long_help; else - return help_strings[u].usage ; + return MU_HELP_STRINGS[u].usage ; } 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* massage_help (const char *help) { diff --git a/mu/mu-help-strings.awk b/mu/mu-help-strings.awk new file mode 100644 index 00000000..81f4606b --- /dev/null +++ b/mu/mu-help-strings.awk @@ -0,0 +1,69 @@ +## Copyright (C) 2012 Dirk-Jan C. Binnema +## +## 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 */" +} diff --git a/mu/mu-help-strings.txt b/mu/mu-help-strings.txt new file mode 100644 index 00000000..0043bd23 --- /dev/null +++ b/mu/mu-help-strings.txt @@ -0,0 +1,115 @@ +#-*-mode:org-*- +# Copyright (C) 2012 Dirk-Jan C. Binnema +# +# 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 [] +#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] [] +#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] +#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] +#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 +#STRING +mu find is the mu command to get help about . +#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] [] +#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] [] +#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] +#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] [] +#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