Commit 7a9a5c13 7a9a5c138a9d226632a4b8c2fa16e4ba22c42697 by Sergey Poznyakoff

mh: improve GNU option parser and help output.

* mh/mh_argp.c (mh_argp_children): Set group number -2, to place
help output between the application help and informational options.
* mh/mhn.c (options): Regroup options,
* mh/pick.c: Likewise.

* mh/ali.c: Reword arg docs.
* mh/anno.c: Likewise.
* mh/burst.c: Likewise.
* mh/comp.c: Likewise.
* mh/fmtcheck.c: Likewise.
* mh/folder.c: Likewise.
* mh/forw.c: Likewise.
* mh/inc.c: Likewise.
* mh/install-mh.c: Likewise.
* mh/mark.c: Likewise.
* mh/mh_argp.c: Likewise.
* mh/mhl.c: Likewise.
* mh/mhn.c: Likewise.
* mh/mhparam.c: Likewise.
* mh/mhpath.c: Likewise.
* mh/pick.c: Likewise.
* mh/refile.c: Likewise.
* mh/repl.c: Likewise.
* mh/rmf.c: Likewise.
* mh/rmm.c: Likewise.
* mh/scan.c: Likewise.
* mh/send.c: Likewise.
* mh/sortm.c: Likewise.
* mh/whom.c: Likewise.
1 parent 7717d6fa
......@@ -26,7 +26,7 @@
static char doc[] = N_("GNU MH ali")"\v"
N_("Use -help to obtain the list of traditional MH options.");
static char args_doc[] = N_("aliases ...");
static char args_doc[] = N_("ALIAS [ALIAS...]");
/* GNU options */
static struct argp_option options[] = {
......
......@@ -22,7 +22,7 @@
static char doc[] = N_("GNU MH anno")"\v"
N_("Options marked with `*' are not yet implemented.\n\
Use -help to obtain the list of traditional MH options.");
static char args_doc[] = N_("[msg [msg...]]");
static char args_doc[] = N_("[MSGLIST]");
/* GNU options */
static struct argp_option options[] = {
......
......@@ -25,7 +25,7 @@
static char doc[] = N_("GNU MH burst")"\v"
N_("Options marked with `*' are not yet implemented.\n\
Use -help to obtain the list of traditional MH options.");
static char args_doc[] = "[msgs]";
static char args_doc[] = N_("[MSGLIST]");
/* GNU options */
static struct argp_option options[] = {
......
......@@ -24,7 +24,7 @@
static char doc[] = N_("GNU MH comp")"\v"
N_("Options marked with `*' are not yet implemented.\n"
"Use -help to obtain the list of traditional MH options.");
static char args_doc[] = "[msg]";
static char args_doc[] = N_("[MSG]");
/* GNU options */
static struct argp_option options[] = {
......
......@@ -21,7 +21,6 @@
static char doc[] = N_("GNU MH fmtcheck")"\v"
N_("Use -help to obtain the list of traditional MH options.");
static char args_doc[] = "";
/* GNU options */
static struct argp_option options[] = {
......@@ -34,7 +33,7 @@ static struct argp_option options[] = {
{ "debug", ARG_DEBUG, NULL, 0,
N_("enable parser debugging output"),},
{ 0 }
{ NULL }
};
/* Traditional MH options */
......@@ -97,7 +96,7 @@ main (int argc, char **argv)
MU_APP_INIT_NLS ();
mh_argp_init ();
mh_argp_parse (&argc, &argv, 0, options, mh_option, args_doc, doc,
mh_argp_parse (&argc, &argv, 0, options, mh_option, NULL, doc,
opt_handler, NULL, NULL);
if (format_str && mh_format_parse (format_str, &format))
......
......@@ -34,7 +34,7 @@
static char doc[] = N_("GNU MH folder")"\v"
N_("Use -help to obtain the list of traditional MH options.");
static char args_doc[] = N_("[action] [msg]");
static char args_doc[] = N_("[ACTION] [MSG]");
static struct argp_option options[] = {
{N_("Actions are:"), 0, 0, OPTION_DOC, NULL, 0 },
......
......@@ -22,7 +22,7 @@
static char doc[] = N_("GNU MH forw")"\v"
N_("Options marked with `*' are not yet implemented.\n\
Use -help to obtain the list of traditional MH options.");
static char args_doc[] = "[msgs]";
static char args_doc[] = N_("[MSGLIST]");
/* GNU options */
static struct argp_option options[] = {
......
......@@ -21,7 +21,7 @@
static char doc[] = N_("GNU MH inc")"\v"
N_("Use -help to obtain the list of traditional MH options.");
static char args_doc[] = N_("[+folder]");
static char args_doc[] = N_("[+FOLDER]");
/* GNU options */
static struct argp_option options[] = {
......
......@@ -19,7 +19,6 @@
static char doc[] = N_("GNU MH install-mh")"\v"
N_("Use -help to obtain the list of traditional MH options.");
static char args_doc[] = "";
/* GNU options */
static struct argp_option options[] = {
......@@ -65,7 +64,7 @@ main (int argc, char **argv)
mh_argp_init ();
mh_auto_install = 0;
mh_argp_parse (&argc, &argv, 0, options, mh_option, args_doc, doc,
mh_argp_parse (&argc, &argv, 0, options, mh_option, NULL, doc,
opt_handler, NULL, NULL);
name = getenv ("MH");
......
......@@ -19,7 +19,7 @@
static char doc[] = N_("GNU MH mark")"\v"
N_("Use -help to obtain the list of traditional MH options.");
static char args_doc[] = "[msgs...]";
static char args_doc[] = N_("[MSGLIST]");
/* GNU options */
static struct argp_option options[] = {
......
......@@ -180,7 +180,7 @@ struct argp mu_debug_argp = {
};
struct argp_child mh_argp_children[] = {
{ &mu_debug_argp, 0, N_("Global debugging settings"), 0 },
{ &mu_debug_argp, 0, N_("Global debugging settings"), -2 },
{ NULL }
};
......
......@@ -23,7 +23,7 @@
static char doc[] = N_("GNU MH mhl")"\v"
N_("Use -help to obtain the list of traditional MH options.");
static char args_doc[] = N_("[files]");
static char args_doc[] = N_("[FILE [FILE...]]");
/* GNU options */
static struct argp_option options[] = {
......
......@@ -27,7 +27,7 @@
static char doc[] = N_("GNU MH mhn")"\v"
N_("Options marked with `*' are not yet implemented.\n\
Use -help to obtain the list of traditional MH options.");
static char args_doc[] = "[msgs]";
static char args_doc[] = N_("[MSGLIST]");
static struct argp_option options[] = {
{"folder", ARG_FOLDER, N_("FOLDER"), 0,
......@@ -35,55 +35,61 @@ static struct argp_option options[] = {
{"file", ARG_FILE, N_("FILE"), 0,
N_("specify file to operate upon"), 0},
{N_("MIME editing options"), 0, NULL, OPTION_DOC, NULL, 5},
#define GRID 10
{N_("MIME editing options"), 0, NULL, OPTION_DOC, NULL, GRID},
{"compose", ARG_COMPOSE, N_("BOOL"), OPTION_ARG_OPTIONAL,
N_("compose the MIME message (default)"), 6},
{"nocompose", ARG_NOCOMPOSE, NULL, OPTION_HIDDEN, "", 6},
{N_("Listing options"), 0, NULL, OPTION_DOC, NULL, 0},
N_("compose the MIME message (default)"), GRID+1},
{"nocompose", ARG_NOCOMPOSE, NULL, OPTION_HIDDEN, "", GRID+1},
#undef GRID
#define GRID 20
{N_("Listing options"), 0, NULL, OPTION_DOC, NULL, GRID},
{"list", ARG_LIST, N_("BOOL"), OPTION_ARG_OPTIONAL,
N_("list the table of contents"), 11 },
{"nolist", ARG_NOLIST, NULL, OPTION_HIDDEN, "", 11 },
N_("list the table of contents"), GRID+1 },
{"nolist", ARG_NOLIST, NULL, OPTION_HIDDEN, "", GRID+1 },
{"headers", ARG_HEADER, N_("BOOL"), OPTION_ARG_OPTIONAL,
N_("print the banner above the listing"), 12},
{"noheaders", ARG_NOHEADERS, NULL, OPTION_HIDDEN, "", 12 },
N_("print the banner above the listing"), GRID+1 },
{"noheaders", ARG_NOHEADERS, NULL, OPTION_HIDDEN, "", GRID+1 },
{"realsize", ARG_REALSIZE, N_("BOOL"), OPTION_ARG_OPTIONAL,
N_("list the decoded sizes"), 12},
{"norealsize", ARG_NOREALSIZE, NULL, OPTION_HIDDEN, "", 12 },
{N_("Display options"), 0, NULL, OPTION_DOC, NULL, 20},
N_("list the decoded sizes"), GRID+1 },
{"norealsize", ARG_NOREALSIZE, NULL, OPTION_HIDDEN, "", GRID+1 },
#undef GRID
#define GRID 40
{N_("Display options"), 0, NULL, OPTION_DOC, NULL, GRID},
{"show", ARG_SHOW, N_("BOOL"), OPTION_ARG_OPTIONAL,
N_("display the contents of the messages"), 21},
{"noshow", ARG_NOSHOW, NULL, OPTION_HIDDEN, "", 21 },
N_("display the contents of the messages"), GRID+1},
{"noshow", ARG_NOSHOW, NULL, OPTION_HIDDEN, "", GRID+1 },
{"serialonly", ARG_SERIALONLY, N_("BOOL"), OPTION_ARG_OPTIONAL,
N_("* display messages serially"), 22},
{"noserialonly", ARG_NOSERIALONLY, NULL, OPTION_HIDDEN, "", 22 },
N_("* display messages serially"), GRID+1},
{"noserialonly", ARG_NOSERIALONLY, NULL, OPTION_HIDDEN, "", GRID+1 },
{"form", ARG_FORM, N_("FILE"), 0,
N_("read mhl format from FILE"), 22},
N_("read mhl format from FILE"), GRID+1},
{"pause", ARG_PAUSE, N_("BOOL"), OPTION_ARG_OPTIONAL,
N_("pause prior to displaying content"), 22},
{"nopause", ARG_NOPAUSE, NULL, OPTION_HIDDEN, "", 22 },
{N_("Saving options"), 0, NULL, OPTION_DOC, NULL, 30},
N_("pause prior to displaying content"), GRID+1},
{"nopause", ARG_NOPAUSE, NULL, OPTION_HIDDEN, "", GRID+1 },
#undef GRID
#define GRID 50
{N_("Saving options"), 0, NULL, OPTION_DOC, NULL, GRID},
{"store", ARG_STORE, N_("BOOL"), OPTION_ARG_OPTIONAL,
N_("store the contents of the messages on disk"), 31},
{"nostore", ARG_NOSTORE, NULL, OPTION_HIDDEN, "", 31 },
N_("write extracted message parts to disk"), GRID+1},
{"nostore", ARG_NOSTORE, NULL, OPTION_HIDDEN, "", GRID+1 },
{"auto", ARG_AUTO, N_("BOOL"), OPTION_ARG_OPTIONAL,
N_("use filenames from the content headers"), 31},
{"noauto", ARG_NOAUTO, NULL, OPTION_HIDDEN, "", 31 },
N_("use filenames from the content headers"), GRID+1},
{"noauto", ARG_NOAUTO, NULL, OPTION_HIDDEN, "", GRID+1 },
{"charset", ARG_CHARSET, N_("NAME"), 0,
N_("use this charset to represent attachment file names"), 31},
{N_("Other options"), 0, NULL, OPTION_DOC, NULL, 40},
N_("use this charset to represent attachment file names"), GRID+1},
#undef GRID
#define GRID 60
{N_("Other options"), 0, NULL, OPTION_DOC, NULL, GRID},
{"part", ARG_PART, N_("PART"), 0,
N_("limit the scope of the operation to the given part"), 41},
N_("limit the scope of the operation to the given part"), GRID+1},
{"type", ARG_TYPE, N_("CONTENT"), 0,
N_("operate on message part with given multipart content"), 41 },
N_("operate on message part with given multipart content"), GRID+1 },
{"verbose", ARG_VERBOSE, N_("BOOL"), OPTION_ARG_OPTIONAL,
N_("print additional information"), 41 },
{"noverbose", ARG_NOVERBOSE, NULL, OPTION_HIDDEN, "", 41 },
N_("print additional information"), GRID+1 },
{"noverbose", ARG_NOVERBOSE, NULL, OPTION_HIDDEN, "", GRID+1 },
{"quiet", ARG_QUIET, 0, 0,
N_("be quiet")},
N_("be quiet"), GRID+1},
#undef GRID
{NULL}
};
......
......@@ -21,7 +21,7 @@
static char doc[] = N_("GNU MH mhparam")"\v"
N_("Use -help to obtain the list of traditional MH options.");
static char args_doc[] = N_("[components]");
static char args_doc[] = N_("[COMPONENT [COMPONENT...]]");
/* GNU options */
static struct argp_option options[] = {
......
......@@ -21,7 +21,7 @@
static char doc[] = N_("GNU MH mhpath")"\v"
N_("Use -help to obtain the list of traditional MH options.");
static char args_doc[] = N_("[+folder] [msgs]");
static char args_doc[] = N_("[+FOLDER] [MSGLIST]");
/* GNU options */
static struct argp_option options[] = {
......
......@@ -37,67 +37,80 @@ letter or followed by a colon, e.g.:\n\
--user-agent: Mailutils\n\
\n\
Use -help to obtain a list of traditional MH options.");
static char args_doc[] = N_("[messages]");
static char args_doc[] = N_("[MSGLIST]");
/* GNU options */
static struct argp_option options[] = {
{"folder", ARG_FOLDER, N_("FOLDER"), 0,
N_("specify folder to operate upon"), 0},
{N_("Specifying search patterns:"), 0, NULL, OPTION_DOC, NULL, 0},
{"component", ARG_COMPONENT, N_("FIELD"), 0,
N_("search the named header field"), 1},
{"pattern", ARG_PATTERN, N_("STRING"), 0,
N_("set pattern to look for"), 1},
{"search", 0, NULL, OPTION_ALIAS, NULL, 1},
{"cflags", ARG_CFLAGS, N_("STRING"), 0,
N_("flags controlling the type of regular expressions. STRING must consist of one or more of the following letters: B=basic, E=extended, I=ignore case, C=case sensitive. Default is \"EI\". The flags remain in effect until the next occurrence of --cflags option. The option must occur right before --pattern or --component option (or its alias).") },
{"cc", ARG_CC, N_("STRING"), 0,
N_("same as --component cc --pattern STRING"), 1},
{"date", ARG_DATE, N_("STRING"), 0,
N_("same as --component date --pattern STRING"), 1},
{"from", ARG_FROM, N_("STRING"), 0,
N_("same as --component from --pattern STRING"), 1},
{"subject", ARG_SUBJECT, N_("STRING"), 0,
N_("same as --component subject --pattern STRING"), 1},
{"to", ARG_TO, N_("STRING"), 0,
N_("same as --component to --pattern STRING"), 1},
{N_("Date constraint operations:"), 0, NULL, OPTION_DOC, NULL, 1},
{"datefield",ARG_DATEFIELD, N_("STRING"), 0,
N_("search in the named date header field (default is `Date:')"), 2},
{"after", ARG_AFTER, N_("DATE"), 0,
N_("match messages after the given date"), 2},
{"before", ARG_BEFORE, N_("DATE"), 0,
N_("match messages before the given date"), 2},
{N_("Logical operations and grouping:"), 0, NULL, OPTION_DOC, NULL, 2},
{"and", ARG_AND, NULL, 0,
N_("logical AND (default)"), 3 },
{"or", ARG_OR, NULL, 0,
N_("logical OR"), 3 },
{"not", ARG_NOT, NULL, 0,
N_("logical NOT"), 3},
{"lbrace", ARG_LBRACE, NULL, 0,
N_("open group"), 3},
{"(", 0, NULL, OPTION_ALIAS, NULL, 3},
{"rbrace", ARG_RBRACE, NULL, 0,
N_("close group"), 3},
{")", 0, NULL, OPTION_ALIAS, NULL, 3},
{N_("Operations over the selected messages:"), 0, NULL, OPTION_DOC, NULL, 3},
{"list", ARG_LIST, N_("BOOL"), OPTION_ARG_OPTIONAL,
N_("list the numbers of the selected messages (default)"), 4},
{"nolist", ARG_NOLIST, NULL, OPTION_HIDDEN, "", 4 },
{"sequence", ARG_SEQUENCE, N_("NAME"), 0,
N_("add matching messages to the given sequence"), 4},
{"public", ARG_PUBLIC, N_("BOOL"), OPTION_ARG_OPTIONAL,
N_("create public sequence"), 4},
{"nopublic", ARG_NOPUBLIC, NULL, OPTION_HIDDEN, "", 4 },
{"zero", ARG_ZERO, N_("BOOL"), OPTION_ARG_OPTIONAL,
N_("empty the sequence before adding messages"), 4},
{"nozero", ARG_NOZERO, NULL, OPTION_HIDDEN, "", 4 },
{NULL},
#define GRID 10
{ "folder", ARG_FOLDER, N_("FOLDER"), 0,
N_("specify folder to operate upon"), GRID },
#undef GRID
#define GRID 20
{ N_("Search patterns"), 0, NULL, OPTION_DOC, NULL, GRID },
{ "component", ARG_COMPONENT, N_("FIELD"), 0,
N_("search the named header field"), GRID+1},
{ "pattern", ARG_PATTERN, N_("STRING"), 0,
N_("set pattern to look for"), GRID+1 },
{ "search", 0, NULL, OPTION_ALIAS, NULL, GRID+1 },
{ "cflags", ARG_CFLAGS, N_("STRING"), 0,
N_("flags controlling the type of regular expressions. STRING must consist of one or more of the following letters: B=basic, E=extended, I=ignore case, C=case sensitive. Default is \"EI\". The flags remain in effect until the next occurrence of --cflags option. The option must occur right before --pattern or --component option (or its alias)."), GRID+1 },
{ "cc", ARG_CC, N_("STRING"), 0,
N_("same as --component cc --pattern STRING"), GRID+1 },
{ "date", ARG_DATE, N_("STRING"), 0,
N_("same as --component date --pattern STRING"), GRID+1 },
{ "from", ARG_FROM, N_("STRING"), 0,
N_("same as --component from --pattern STRING"), GRID+1 },
{ "subject", ARG_SUBJECT, N_("STRING"), 0,
N_("same as --component subject --pattern STRING"), GRID+1 },
{ "to", ARG_TO, N_("STRING"), 0,
N_("same as --component to --pattern STRING"), GRID+1 },
#undef GRID
#define GRID 30
{ N_("Date constraint operations"), 0, NULL, OPTION_DOC, NULL, GRID },
{ "datefield",ARG_DATEFIELD, N_("STRING"), 0,
N_("search in the named date header field (default is `Date:')"), GRID+1 },
{ "after", ARG_AFTER, N_("DATE"), 0,
N_("match messages after the given date"), GRID+1 },
{ "before", ARG_BEFORE, N_("DATE"), 0,
N_("match messages before the given date"), GRID+1 },
#undef GRID
#define GRID 40
{ N_("Logical operations and grouping"), 0, NULL, OPTION_DOC, NULL, GRID },
{ "and", ARG_AND, NULL, 0,
N_("logical AND (default)"), GRID+1 },
{ "or", ARG_OR, NULL, 0,
N_("logical OR"), GRID+1 },
{ "not", ARG_NOT, NULL, 0,
N_("logical NOT"), GRID+1 },
{ "lbrace", ARG_LBRACE, NULL, 0,
N_("open group"), GRID+1 },
{ "(", 0, NULL, OPTION_ALIAS, NULL, GRID+1 },
{ "rbrace", ARG_RBRACE, NULL, 0,
N_("close group"), GRID+1},
{ ")", 0, NULL, OPTION_ALIAS, NULL, GRID+1 },
#undef GRID
#define GRID 50
{ N_("Operations over the selected messages"), 0, NULL, OPTION_DOC, NULL,
GRID },
{ "list", ARG_LIST, N_("BOOL"), OPTION_ARG_OPTIONAL,
N_("list the numbers of the selected messages (default)"), GRID+1 },
{ "nolist", ARG_NOLIST, NULL, OPTION_HIDDEN, "", GRID+1 },
{ "sequence", ARG_SEQUENCE, N_("NAME"), 0,
N_("add matching messages to the given sequence"), GRID+1 },
{ "public", ARG_PUBLIC, N_("BOOL"), OPTION_ARG_OPTIONAL,
N_("create public sequence"), GRID+1 },
{ "nopublic", ARG_NOPUBLIC, NULL, OPTION_HIDDEN, "", GRID+1 },
{ "zero", ARG_ZERO, N_("BOOL"), OPTION_ARG_OPTIONAL,
N_("empty the sequence before adding messages"), GRID+1 },
{ "nozero", ARG_NOZERO, NULL, OPTION_HIDDEN, "", GRID+1 },
#undef GRID
{ NULL }
};
/* Traditional MH options */
......
......@@ -27,7 +27,7 @@
static char doc[] = N_("GNU MH refile")"\v"
N_("Options marked with `*' are not yet implemented.\n\
Use -help to obtain the list of traditional MH options.");
static char args_doc[] = N_("messages folder [folder...]");
static char args_doc[] = N_("MSGLIST FOLDER [FOLDER...]");
/* GNU options */
static struct argp_option options[] = {
......
......@@ -25,7 +25,7 @@
static char doc[] = N_("GNU MH repl")"\v"
N_("Options marked with `*' are not yet implemented.\n\
Use -help to obtain the list of traditional MH options.");
static char args_doc[] = N_("[+folder] [msg]");
static char args_doc[] = N_("[+FOLDER] [MESSAGE]");
/* GNU options */
......
......@@ -30,7 +30,7 @@
static char doc[] = N_("GNU MH rmf")"\v"
N_("Use -help to obtain the list of traditional MH options.");
static char args_doc[] = N_("[+folder]");
static char args_doc[] = N_("[+FOLDER]");
/* GNU options */
static struct argp_option options[] = {
......
......@@ -21,7 +21,7 @@
static char doc[] = N_("GNU MH rmm")"\v"
N_("Use -help to obtain the list of traditional MH options.");
static char args_doc[] = N_("[+folder] [msgs]");
static char args_doc[] = N_("[+FOLDER] [MSGLIST]");
/* GNU options */
static struct argp_option options[] = {
......
......@@ -28,7 +28,7 @@
static char doc[] = N_("GNU MH scan")"\v"
N_("Use -help to obtain the list of traditional MH options.");
static char args_doc[] = N_("[+folder] [msgs]");
static char args_doc[] = N_("[+FOLDER] [MSGLIST]");
/* GNU options */
static struct argp_option options[] = {
......
......@@ -26,7 +26,7 @@
static char doc[] = N_("GNU MH send")"\v"
N_("Options marked with `*' are not yet implemented.\n\
Use -help to obtain the list of traditional MH options.");
static char args_doc[] = N_("file [file...]");
static char args_doc[] = N_("FILE [FILE...]");
/* GNU options */
static struct argp_option options[] = {
......
......@@ -24,7 +24,7 @@
static char doc[] = N_("GNU MH sortm")"\v"
N_("Use -help to obtain the list of traditional MH options.");
static char args_doc[] = N_("[msgs]");
static char args_doc[] = N_("[MSGLIST]");
#define ARG_QUICKSORT 1024
#define ARG_SHELL 1025
......
......@@ -19,7 +19,7 @@
static char doc[] = N_("GNU MH whom")"\v"
N_("Use -help to obtain the list of traditional MH options.");
static char args_doc[] = "[file]";
static char args_doc[] = "[FILE]";
/* GNU options */
static struct argp_option options[] = {
......