Commit f0837cca f0837cca3b625cbeb6da401726b32c4d75f21c17 by Sergey Poznyakoff

Fixed option handling

1 parent 16354fd3
......@@ -23,33 +23,36 @@
const char *argp_program_version = "comp (" PACKAGE_STRING ")";
static char doc[] = N_("GNU MH comp\v"
"Options marked with `*' are not yet implemented.\n"
"Use -help to obtain the list of traditional MH options.");
static char args_doc[] = "[msg]";
#define ARG_NOEDIT 1
#define ARG_WHATNOWPROC 2
#define ARG_NOWHATNOWPROC 3
#define ARG_NODRAFTFOLDER 4
#define ARG_FILE 5
/* GNU options */
static struct argp_option options[] = {
{"build", 'b', 0, 0,
{"build", ARG_BUILD, 0, 0,
N_("Build the draft and quit immediately.")},
{"draftfolder", 'd', N_("FOLDER"), 0,
{"draftfolder", ARG_DRAFTFOLDER, N_("FOLDER"), 0,
N_("Specify the folder for message drafts")},
{"nodraftfolder", ARG_NODRAFTFOLDER, 0, 0,
N_("Undo the effect of the last --draftfolder option")},
{"draftmessage" , 'm', N_("MSG"), 0,
{"draftmessage" , ARG_DRAFTMESSAGE, N_("MSG"), 0,
N_("Invoke the draftmessage facility")},
{"folder", 'f', N_("FOLDER"), 0, N_("Specify folder to operate upon")},
{"file", ARG_FILE, N_("FILE"), 0, N_("Use FILE as the message draft")},
{"editor", 'e', N_("PROG"), 0, N_("Set the editor program to use")},
{"noedit", ARG_NOEDIT, 0, 0, N_("Suppress the initial edit")},
{"form", 'F', N_("FILE"), 0, N_("Read format from given file")},
{"whatnowproc", ARG_WHATNOWPROC, N_("PROG"), 0,
N_("Set the replacement for whatnow program")},
{"use", 'u', N_("BOOL"), OPTION_ARG_OPTIONAL, N_("Use draft file preserved after the last session") },
{"folder", ARG_FOLDER, N_("FOLDER"), 0,
N_("Specify folder to operate upon")},
{"file", ARG_FILE, N_("FILE"), 0,
N_("Use FILE as the message draft")},
{"editor", ARG_EDITOR, N_("PROG"), 0,
N_("Set the editor program to use")},
{"noedit", ARG_NOEDIT, 0, 0,
N_("Suppress the initial edit")},
{"form", ARG_FORM, N_("FILE"), 0,
N_("Read format from given file")},
{"whatnowproc", ARG_WHATNOWPROC, N_("PROG"), 0,
N_("* Set the replacement for whatnow program")},
{"nowhatnowproc", ARG_NOWHATNOWPROC, NULL, 0,
N_("* Ignore whatnowproc variable. Use standard `whatnow' shell instead.")},
{"use", ARG_USE, N_("BOOL"), OPTION_ARG_OPTIONAL,
N_("Use draft file preserved after the last session") },
{ 0 }
};
......@@ -86,33 +89,32 @@ opt_handler (int key, char *arg, void *unused)
{
switch (key)
{
case 'b':
case ARG_NOWHATNOWPROC:
case ARG_BUILD:
build_only = 1;
break;
case 'd':
case ARG_DRAFTFOLDER:
wh_env.draftfolder = arg;
break;
case 'e':
case ARG_EDITOR:
wh_env.editor = arg;
break;
case '+':
case 'f':
case ARG_FOLDER:
current_folder = arg;
break;
case 'F':
case ARG_FORM:
formfile = mh_expand_name (MHLIBDIR, arg, 0);
break;
case 'm':
case ARG_DRAFTMESSAGE:
wh_env.draftmessage = arg;
break;
case 'u':
case ARG_USE:
use_draft = is_true (arg);
break;
......@@ -129,6 +131,7 @@ opt_handler (int key, char *arg, void *unused)
break;
case ARG_WHATNOWPROC:
case ARG_NOWHATNOWPROC:
mh_error (_("option is not yet implemented"));
exit (1);
......
......@@ -26,10 +26,14 @@ static char args_doc[] = "";
/* GNU options */
static struct argp_option options[] = {
{"form", 'F', N_("FILE"), 0, N_("Read format from given file")},
{"format", 't', N_("FORMAT"), 0, N_("Use this format string")},
{"dump", 'd', NULL, 0, N_("Dump the listing of compiled format code")},
{ "debug", 'D', NULL, 0, N_("Enable parser debugging output"),},
{"form", ARG_FORM, N_("FILE"), 0,
N_("Read format from given file")},
{"format", ARG_FORMAT, N_("FORMAT"), 0,
N_("Use this format string")},
{"dump", ARG_DUMP, NULL, 0,
N_("Dump the listing of compiled format code")},
{ "debug", ARG_DEBUG, NULL, 0,
N_("Enable parser debugging output"),},
{ 0 }
};
......@@ -64,19 +68,19 @@ opt_handler (int key, char *arg, void *unused)
{
switch (key)
{
case 'F':
case ARG_FORM:
mh_read_formfile (arg, &format_str);
break;
case 't':
case ARG_FORMAT:
format_str = arg;
break;
case 'd':
case ARG_DUMP:
action = action_dump;
break;
case 'D':
case ARG_DEBUG:
mh_format_debug (1);
break;
......
......@@ -26,19 +26,28 @@ static char args_doc[] = N_("[+folder]");
/* GNU options */
static struct argp_option options[] = {
{"file", 'i', N_("FILE"), 0, N_("Incorporate mail from named file")},
{"folder", 'f', N_("FOLDER"), 0, N_("Specify folder to incorporate mail to")},
{"audit", 'a', N_("FILE"), 0, N_("Enable audit")},
{"noaudit", 'n', 0, 0, N_("Disable audit")},
{"changecur", 'c', N_("BOOL"), OPTION_ARG_OPTIONAL,
{"file", ARG_FILE, N_("FILE"), 0,
N_("Incorporate mail from named file")},
{"folder", ARG_FOLDER, N_("FOLDER"), 0,
N_("Specify folder to incorporate mail to")},
{"audit", ARG_AUDIT, N_("FILE"), 0,
N_("Enable audit")},
{"noaudit", ARG_NOAUDIT, 0, 0,
N_("Disable audit")},
{"changecur", ARG_CHANGECUR, N_("BOOL"), OPTION_ARG_OPTIONAL,
N_("Mark first incorporated message as current (default)")},
{"form", 'F', N_("FILE"), 0, N_("Read format from given file")},
{"format", 't', N_("FORMAT"), 0, N_("Use this format string")},
{"truncate", 'T', N_("BOOL"), OPTION_ARG_OPTIONAL,
{"form", ARG_FORM, N_("FILE"), 0,
N_("Read format from given file")},
{"format", ARG_FORMAT, N_("FORMAT"), 0,
N_("Use this format string")},
{"truncate", ARG_TRUNCATE, N_("BOOL"), OPTION_ARG_OPTIONAL,
N_("Truncate source mailbox after incorporating (default)")},
{"width", 'w', N_("NUMBER"), 0, N_("Set output width")},
{"quiet", 'q', 0, 0, N_("Be quiet")},
{"license", 'l', 0, 0, N_("Display software license"), -1},
{"width", ARG_WIDTH, N_("NUMBER"), 0,
N_("Set output width")},
{"quiet", ARG_QUIET, 0, 0,
N_("Be quiet")},
{"license", ARG_LICENSE, 0, 0,
N_("Display software license"), -1},
{ 0 }
};
......@@ -76,36 +85,36 @@ opt_handler (int key, char *arg, void *unused)
append_folder = mh_global_profile_get ("Inbox", "inbox");
break;
case 'a':
case ARG_AUDIT:
audit_file = arg;
break;
case 'n':
case ARG_NOAUDIT:
audit_file = NULL;
break;
case 'c':
case ARG_CHANGECUR:
changecur = is_true(arg);
break;
case '+':
case 'f':
case ARG_FOLDER:
append_folder = arg;
break;
case 'F':
case ARG_FORM:
mh_read_formfile (arg, &format_str);
break;
case 'i':
case ARG_FILE:
input_file = arg;
break;
case 'T':
case ARG_TRUNCATE:
truncate_source = is_true(arg);
break;
case 'w':
case ARG_WIDTH:
width = strtoul (arg, NULL, 0);
if (!width)
{
......@@ -114,11 +123,11 @@ opt_handler (int key, char *arg, void *unused)
}
break;
case 'q':
case ARG_QUIET:
quiet = 1;
break;
case 'l':
case ARG_LICENSE:
mh_license (argp_program_version);
break;
......
......@@ -26,7 +26,8 @@ static char args_doc[] = N_("[+folder] [msgs]");
/* GNU options */
static struct argp_option options[] = {
{"folder", 'f', N_("FOLDER"), 0, N_("Specify folder to operate upon")},
{"folder", ARG_FOLDER, N_("FOLDER"), 0,
N_("Specify folder to operate upon")},
{ 0 }
};
......@@ -41,7 +42,7 @@ opt_handler (int key, char *arg, void *unused)
switch (key)
{
case '+':
case 'f':
case ARG_FOLDER:
current_folder = arg;
break;
......
......@@ -31,16 +31,18 @@ static char args_doc[] = N_("messages folder [folder...]");
/* GNU options */
static struct argp_option options[] = {
{"folder", 'f', N_("FOLDER"), 0, N_("Specify folder to operate upon")},
{"draft", 'd', NULL, 0, N_("Use <mh-dir>/draft as the source message")},
{"link", 'l', N_("BOOL"), OPTION_ARG_OPTIONAL,
{"folder", ARG_FOLDER, N_("FOLDER"), 0,
N_("Specify folder to operate upon")},
{"draft", ARG_DRAFT, NULL, 0,
N_("Use <mh-dir>/draft as the source message")},
{"link", ARG_LINK, N_("BOOL"), OPTION_ARG_OPTIONAL,
N_("(not implemented) Preserve the source folder copy")},
{"preserve", 'p', N_("BOOL"), OPTION_ARG_OPTIONAL,
{"preserve", ARG_PRESERVE, N_("BOOL"), OPTION_ARG_OPTIONAL,
N_("(not implemented) Try to preserve message sequence numbers")},
{"source", 's', N_("FOLDER"), 0,
{"source", ARG_SOURCE, N_("FOLDER"), 0,
N_("Specify source folder. FOLDER will become the current folder after the program exits.")},
{"src", 0, NULL, OPTION_ALIAS, NULL},
{"file", 'F', N_("FILE"), 0, N_("Use FILE as the source message")},
{"file", ARG_FILE, N_("FILE"), 0, N_("Use FILE as the source message")},
{ 0 }
};
......@@ -135,27 +137,27 @@ opt_handler (int key, char *arg, void *unused)
switch (key)
{
case '+':
case 'f':
case ARG_FOLDER:
add_folder (arg);
break;
case 'd':
case ARG_DRAFT:
source_file = mh_expand_name (NULL, "draft", 0);
break;
case 'l':
case ARG_LINK:
link_flag = is_true(arg);
break;
case 'p':
case ARG_PRESERVE:
preserve_flag = is_true(arg);
break;
case 's':
case ARG_SOURCE:
current_folder = arg;
break;
case 'F':
case ARG_FILE:
source_file = arg;
break;
......@@ -219,7 +221,7 @@ main (int argc, char **argv)
mh_error (_("both message set and source file given"));
exit (1);
}
mbox = mh_open_msg_file (source_file);
mbox = mh_open_msg_file (NULL, source_file);
mh_msgset_parse (mbox, &msgset, 0, NULL, "first");
}
else
......
......@@ -23,49 +23,44 @@
const char *argp_program_version = "reply (" PACKAGE_STRING ")";
static char doc[] = N_("GNU MH repl\v"
"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]");
#define ARG_NOEDIT 1
#define ARG_FCC 2
#define ARG_FILTER 3
#define ARG_INPLACE 4
#define ARG_QUERY 5
#define ARG_WHATNOWPROC 6
#define ARG_NOWHATNOWPROC 7
#define ARG_NODRAFTFOLDER 8
/* GNU options */
static struct argp_option options[] = {
{"annotate", 'a', N_("BOOL"), OPTION_ARG_OPTIONAL,
N_("Add Replied: header to the message being replied to")},
{"build", 'b', 0, 0,
{"annotate", ARG_ANNOTATE, N_("BOOL"), OPTION_ARG_OPTIONAL,
N_("* Add Replied: header to the message being replied to")},
{"build", ARG_BUILD, 0, 0,
N_("Build the draft and quit immediately.")},
{"draftfolder", 'd', N_("FOLDER"), 0,
{"draftfolder", ARG_DRAFTFOLDER, N_("FOLDER"), 0,
N_("Specify the folder for message drafts")},
{"nodraftfolder", ARG_NODRAFTFOLDER, 0, 0,
N_("Undo the effect of the last --draftfolder option")},
{"draftmessage" , 'm', N_("MSG"), 0,
{"draftmessage" , ARG_DRAFTMESSAGE, N_("MSG"), 0,
N_("Invoke the draftmessage facility")},
{"cc", 'c', "{all|to|cc|me}", 0,
{"cc", ARG_CC, "{all|to|cc|me}", 0,
N_("Specify whom to place on the Cc: list of the reply")},
{"nocc", 'n', "{all|to|cc|me}", 0,
{"nocc", ARG_NOCC, "{all|to|cc|me}", 0,
N_("Specify whom to remove from the Cc: list of the reply")},
{"folder", 'f', N_("FOLDER"), 0, N_("Specify folder to operate upon")},
{"editor", 'e', N_("PROG"), 0, N_("Set the editor program to use")},
{"folder", ARG_FOLDER, N_("FOLDER"), 0, N_("Specify folder to operate upon")},
{"editor", ARG_EDITOR, N_("PROG"), 0, N_("Set the editor program to use")},
{"noedit", ARG_NOEDIT, 0, 0, N_("Suppress the initial edit")},
{"fcc", ARG_FCC, N_("FOLDER"), 0, N_("Set the folder to receive Fcc's.")},
{"fcc", ARG_FCC, N_("FOLDER"), 0, N_("* Set the folder to receive Fcc's.")},
{"filter", ARG_FILTER, N_("PROG"), 0,
N_("Set the filter program to preprocess the body of the message being replied")},
{"form", 'F', N_("FILE"), 0, N_("Read format from given file")},
N_("* Set the filter program to preprocess the body of the message being replied")},
{"form", ARG_FORM, N_("FILE"), 0, N_("Read format from given file")},
{"inplace", ARG_INPLACE, N_("BOOL"), OPTION_ARG_OPTIONAL,
N_("Annotate the message in place")},
N_("* Annotate the message in place")},
{"query", ARG_QUERY, N_("BOOL"), OPTION_ARG_OPTIONAL,
N_("Query for addresses to place in To: and Cc: lists")},
{"width", 'w', N_("NUMBER"), 0, N_("Set output width")},
N_("* Query for addresses to place in To: and Cc: lists")},
{"width", ARG_WIDTH, N_("NUMBER"), 0, N_("Set output width")},
{"whatnowproc", ARG_WHATNOWPROC, N_("PROG"), 0,
N_("Set the replacement for whatnow program")},
{"use", 'u', N_("BOOL"), OPTION_ARG_OPTIONAL, N_("Use draft file preserved after the last session") },
N_("* Set the replacement for whatnow program")},
{"nowhatnowproc", ARG_NOWHATNOWPROC, NULL, 0,
N_("* Ignore whatnowproc variable. Use standard `whatnow' shell instead.")},
{"use", ARG_USE, N_("BOOL"), OPTION_ARG_OPTIONAL, N_("Use draft file preserved after the last session") },
{ 0 }
};
......@@ -133,47 +128,46 @@ opt_handler (int key, char *arg, void *unused)
switch (key)
{
case 'b':
case ARG_NOWHATNOWPROC:
case ARG_BUILD:
build_only = 1;
break;
case 'c':
case ARG_CC:
rcpt_mask |= decode_cc_flag ("-cc", arg);
break;
case 'n':
case ARG_NOCC:
rcpt_mask &= ~decode_cc_flag ("-nocc", arg);
break;
case 'd':
case ARG_DRAFTFOLDER:
wh_env.draftfolder = arg;
break;
case 'e':
case ARG_EDITOR:
wh_env.editor = arg;
break;
case '+':
case 'f':
case ARG_FOLDER:
current_folder = arg;
break;
case 'F':
case ARG_FORM:
s = mh_expand_name (MHLIBDIR, arg, 0);
mh_read_formfile (s, &format_str);
free (s);
break;
case 'm':
case ARG_DRAFTMESSAGE:
wh_env.draftmessage = arg;
break;
case 'u':
case ARG_USE:
use_draft = is_true (arg);
break;
case 'w':
case ARG_WIDTH:
width = strtoul (arg, NULL, 0);
if (!width)
{
......@@ -194,11 +188,12 @@ opt_handler (int key, char *arg, void *unused)
query_mode = is_true (arg);
break;
case 'a':
case ARG_ANNOTATE:
case ARG_FCC:
case ARG_FILTER:
case ARG_INPLACE:
case ARG_WHATNOWPROC:
case ARG_NOWHATNOWPROC:
mh_error (_("option is not yet implemented"));
exit (1);
......
......@@ -35,10 +35,12 @@ static char args_doc[] = N_("[+folder]");
/* GNU options */
static struct argp_option options[] = {
{"folder", 'f', N_("FOLDER"), 0, N_("Specify the folder to delete")},
{"interactive", 'i', N_("BOOL"), OPTION_ARG_OPTIONAL,
{"folder", ARG_FOLDER, N_("FOLDER"), 0,
N_("Specify the folder to delete")},
{"interactive", ARG_INTERACTIVE, N_("BOOL"), OPTION_ARG_OPTIONAL,
N_("Interactive mode: ask for confirmation before removing each folder")},
{"recursive", 'r', NULL, 0, N_("Recursively delete all subfolders")},
{"recursive", ARG_RECURSIVE, NULL, 0,
N_("Recursively delete all subfolders")},
{ 0 }
};
......@@ -58,16 +60,16 @@ opt_handler (int key, char *arg, void *unused)
switch (key)
{
case '+':
case 'f':
case ARG_FOLDER:
explicit_folder = 1;
current_folder = arg;
break;
case 'i':
case ARG_INTERACTIVE:
interactive = is_true (arg);
break;
case 'r':
case ARG_RECURSIVE:
recurse = is_true (arg);
break;
......
......@@ -26,7 +26,8 @@ static char args_doc[] = N_("[+folder] [msgs]");
/* GNU options */
static struct argp_option options[] = {
{"folder", 'f', N_("FOLDER"), 0, N_("Specify folder to operate upon")},
{"folder", ARG_FOLDER, N_("FOLDER"), 0,
N_("Specify folder to operate upon")},
{ 0 }
};
......@@ -41,7 +42,7 @@ opt_handler (int key, char *arg, void *unused)
switch (key)
{
case '+':
case 'f':
case ARG_FOLDER:
current_folder = arg;
break;
......
......@@ -33,17 +33,25 @@ static char args_doc[] = N_("[+folder] [msgs]");
/* GNU options */
static struct argp_option options[] = {
{"folder", 'f', N_("FOLDER"), 0, N_("Specify folder to scan")},
{"clear", 'c', N_("BOOL"), OPTION_ARG_OPTIONAL,
{"folder", ARG_FOLDER, N_("FOLDER"), 0,
N_("Specify folder to scan")},
{"clear", ARG_CLEAR, N_("BOOL"), OPTION_ARG_OPTIONAL,
N_("Clear screen after displaying the list")},
{"form", 'F', N_("FILE"), 0, N_("Read format from given file")},
{"format", 't', N_("FORMAT"), 0, N_("Use this format string")},
{"header", 'H', N_("BOOL"), OPTION_ARG_OPTIONAL, N_("Display header")},
{"width", 'w', N_("NUMBER"), 0, N_("Set output width")},
{"reverse", 'r', N_("BOOL"), OPTION_ARG_OPTIONAL, N_("List messages in reverse order")},
{"file", 'i', N_("FILE"), 0, N_("[Not yet implemented]")},
{"form", ARG_FORM, N_("FILE"), 0,
N_("Read format from given file")},
{"format", ARG_FORMAT, N_("FORMAT"), 0,
N_("Use this format string")},
{"header", ARG_HEADER, N_("BOOL"), OPTION_ARG_OPTIONAL,
N_("Display header")},
{"width", ARG_WIDTH, N_("NUMBER"), 0,
N_("Set output width")},
{"reverse", ARG_REVERSE, N_("BOOL"), OPTION_ARG_OPTIONAL,
N_("List messages in reverse order")},
{"file", ARG_FILE, N_("FILE"), 0,
N_("[Not yet implemented]")},
{"license", 'l', 0, 0, N_("Display software license"), -1},
{"license", ARG_LICENSE, 0, 0,
N_("Display software license"), -1},
{ 0 }
};
......@@ -81,27 +89,27 @@ opt_handler (int key, char *arg, void *unused)
switch (key)
{
case '+':
case 'f':
case ARG_FOLDER:
current_folder = arg;
break;
case 'c':
case ARG_CLEAR:
clear = is_true(arg);
break;
case 'F':
case ARG_FORM:
mh_read_formfile (arg, &format_str);
break;
case 't':
case ARG_FORMAT:
format_str = arg;
break;
case 'H':
case ARG_HEADER:
header = is_true(arg);
break;
case 'w':
case ARG_WIDTH:
width = strtoul (arg, NULL, 0);
if (!width)
{
......@@ -110,15 +118,15 @@ opt_handler (int key, char *arg, void *unused)
}
break;
case 'r':
case ARG_REVERSE:
reverse = is_true(arg);
break;
case 'i':
mh_error (_("'i' is not yet implemented."));
case ARG_FILE:
mh_error (_("option is not yet implemented"));
break;
case 'l':
case ARG_LICENSE:
mh_license (argp_program_version);
break;
......
......@@ -23,20 +23,17 @@ const char *argp_program_version = "whatnow (" PACKAGE_STRING ")";
static char doc[] = "GNU MH whatnow";
static char args_doc[] = N_("[FILE]");
#define ARG_NODRAFTFOLDER 1
#define ARG_NOEDIT 2
/* GNU options */
static struct argp_option options[] = {
{"draftfolder", 'd', N_("FOLDER"), 0,
{"draftfolder", ARG_DRAFTFOLDER, N_("FOLDER"), 0,
N_("Specify the folder for message drafts")},
{"nodraftfolder", ARG_NODRAFTFOLDER, 0, 0,
N_("Undo the effect of the last --draftfolder option")},
{"draftmessage" , 'm', N_("MSG"), 0,
{"draftmessage" , ARG_DRAFTMESSAGE, N_("MSG"), 0,
N_("Invoke the draftmessage facility")},
{"editor", 'e', N_("PROG"), 0, N_("Set the editor program to use")},
{"editor", ARG_EDITOR, N_("PROG"), 0, N_("Set the editor program to use")},
{"noedit", ARG_NOEDIT, 0, 0, N_("Suppress the initial edit")},
{"prompt", 'p', N_("STRING"), 0, N_("Set the prompt")},
{"prompt", ARG_PROMPT, N_("STRING"), 0, N_("Set the prompt")},
{ NULL }
};
......@@ -59,11 +56,11 @@ opt_handler (int key, char *arg, void *unused)
{
switch (key)
{
case 'd':
case ARG_DRAFTFOLDER:
wh_env.draftfolder = arg;
break;
case 'e':
case ARG_EDITOR:
wh_env.editor = arg;
break;
......@@ -75,11 +72,11 @@ opt_handler (int key, char *arg, void *unused)
initial_edit = 0;
break;
case 'm':
case ARG_DRAFTMESSAGE:
wh_env.draftmessage = arg;
break;
case 'p':
case ARG_PROMPT:
wh_env.prompt = arg;
break;
......