[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[SCM] GNU Mailutils branch, master, updated. release-2.2-418-gfc93493
From: |
Sergey Poznyakoff |
Subject: |
[SCM] GNU Mailutils branch, master, updated. release-2.2-418-gfc93493 |
Date: |
Tue, 01 Nov 2011 10:24:37 +0000 |
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "GNU Mailutils".
http://git.savannah.gnu.org/cgit/mailutils.git/commit/?id=fc93493b146bd36a01cd689c08a4ddaf95231517
The branch, master has been updated
via fc93493b146bd36a01cd689c08a4ddaf95231517 (commit)
from 5454ed7909380a8fa934b1e1a89d59e62174ab64 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commit fc93493b146bd36a01cd689c08a4ddaf95231517
Author: Sergey Poznyakoff <address@hidden>
Date: Tue Nov 1 12:20:29 2011 +0200
mu dbm: improve command line interface.
* mu/dbm.c: Use subcommand (not options) to select operation mode.
New subcommand: dump.
* mu/help.c (mutool_help): Make sure argv[0] contains program and
command name.
* mu/mu.c (main): Likewise.
-----------------------------------------------------------------------
Summary of changes:
mu/dbm.c | 110 ++++++++++++++++++++++++++++++++++--------------------------
mu/help.c | 3 +-
mu/mu.c | 4 ++
3 files changed, 68 insertions(+), 49 deletions(-)
diff --git a/mu/dbm.c b/mu/dbm.c
index a33d593..9cf3556 100644
--- a/mu/dbm.c
+++ b/mu/dbm.c
@@ -31,13 +31,22 @@
#include "mu.h"
#include "xalloc.h"
-static char dbm_doc[] = N_("mu dbm - DBM management tool");
+static char dbm_doc[] = N_("mu dbm - DBM management tool\n"
+"Valid COMMANDs are:\n"
+"\n"
+" create or load - create the database\n"
+" list - list contents of the database\n"
+" delete - delete specified keys from the database\n"
+" add - add records to the database\n"
+" replace - add records replacing ones with matching keys\n");
char dbm_docstring[] = N_("DBM management tool");
-static char dbm_args_doc[] = N_("FILE [KEY...]");
+static char dbm_args_doc[] = N_("COMMAND FILE [KEY...]");
enum mode
{
+ mode_unspecified,
mode_list,
+ mode_dump,
mode_create,
mode_delete,
mode_add,
@@ -75,7 +84,7 @@ static enum key_type key_type = key_literal;
static int case_sensitive = 1;
static int include_zero = -1;
-static int suppress_header;
+static int suppress_header = -1;
static void
@@ -306,9 +315,13 @@ static struct xfer_format format_tab[] = {
{ NULL }
};
static int format_count = MU_ARRAY_SIZE (format_tab) - 1;
-
-static struct xfer_format *format = format_tab;
+
+#define DEFAULT_LIST_FORMAT (&format_tab[0])
+#define DEFAULT_DUMP_FORMAT (&format_tab[1])
+
+static struct xfer_format *format;
static const char *dump_format_version;
+
static int
read_data (struct iobuf *inp, struct mu_dbm_datum *key,
@@ -328,8 +341,6 @@ static int
select_format (const char *version)
{
struct xfer_format *fmt;
- char *p;
- unsigned long n;
dump_format_version = version;
for (fmt = format_tab; fmt->name; fmt++)
@@ -338,15 +349,6 @@ select_format (const char *version)
format = fmt;
return 0;
}
-
- /* Try version number */
- errno = 0;
- n = strtoul (version, &p, 10);
- if ((*p == 0 || *p == '.') && errno == 0 && n < format_count)
- {
- format = format_tab + n;
- return 0;
- }
mu_error (_("unsupported format version: %s"), version);
return 1;
}
@@ -1427,16 +1429,9 @@ delete_database (int argc, char **argv)
*/
static struct argp_option dbm_options[] = {
- { NULL, 0, NULL, 0, N_("Operation mode"), 0},
- { "create", 'c', NULL, 0, N_("create the database") },
- { "list", 'l', NULL, 0, N_("list contents of the database") },
- { "delete", 'd', NULL, 0, N_("delete specified keys from the database") },
- { "add", 'a', NULL, 0, N_("add records to the database") },
- { "replace",'r', NULL, 0, N_("add records replacing ones with matching
keys") },
-
- { NULL, 0, NULL, 0, N_("Create modifiers"), 0},
+ { NULL, 0, NULL, 0, N_("Create Options"), 0},
{ "file", 'f', N_("FILE"), 0,
- N_("read input from FILE (with --create, --delete, --add and --replace)")
},
+ N_("read input from FILE (with create, delete, add and replace)") },
{ "permissions", 'p', N_("NUM"), 0,
N_("set permissions on the created database") },
{ "user", 'u', N_("USER"), 0,
@@ -1449,19 +1444,19 @@ static struct argp_option dbm_options[] = {
N_("ignore meta-information from input file headers") },
{ "ignore-directives", 'I', N_("NAMES"), 0,
N_("ignore the listed directives") },
- { NULL, 0, NULL, 0, N_("List modifiers"), 0},
+ { NULL, 0, NULL, 0, N_("List and Dump Options"), 0},
{ "format", 'H', N_("TYPE"), 0,
N_("select output format") },
{ "no-header", 'q', NULL, 0,
N_("suppress format header") },
- { NULL, 0, NULL, 0, N_("List and Delete modifiers"), 0},
+ { NULL, 0, NULL, 0, N_("List, Dump and Delete Options"), 0},
{ "glob", 'G', NULL, 0,
N_("treat keys as globbing patterns") },
{ "regex", 'R', NULL, 0,
N_("treat keys as regular expressions") },
{ "ignore-case", 'i', NULL, 0,
N_("case-insensitive matches") },
- { NULL, 0, NULL, 0, N_("Data length modifiers"), 0 },
+ { NULL, 0, NULL, 0, N_("Options for Use with Format 0.0"), 0 },
{ "count-null", 'N', NULL, 0,
N_("data length accounts for terminating zero") },
{ "no-count-null", 'n', NULL, 0,
@@ -1474,26 +1469,6 @@ dbm_parse_opt (int key, char *arg, struct argp_state
*state)
{
switch (key)
{
- case 'c':
- mode = mode_create;
- break;
-
- case 'l':
- mode = mode_list;
- break;
-
- case 'd':
- mode = mode_delete;
- break;
-
- case 'a':
- mode = mode_add;
- break;
-
- case 'r':
- mode = mode_replace;
- break;
-
case 'f':
input_file = arg;
break;
@@ -1603,6 +1578,18 @@ static struct argp dbm_argp = {
NULL
};
+struct mu_kwd mode_tab[] =
+{
+ { "add", mode_add },
+ { "create", mode_create },
+ { "load", mode_create },
+ { "list", mode_list },
+ { "replace", mode_replace },
+ { "delete", mode_delete },
+ { "dump", mode_dump },
+ { NULL }
+};
+
int
mutool_dbm (int argc, char **argv)
{
@@ -1616,6 +1603,21 @@ mutool_dbm (int argc, char **argv)
if (argc == 0)
{
+ mu_error (_("subcommand not given"));
+ exit (EX_USAGE);
+ }
+
+ if (mu_kwd_xlat_name (mode_tab, argv[0], &index))
+ {
+ mu_error (_("unknown subcommand: %s"), argv[0]);
+ exit (EX_USAGE);
+ }
+ mode = index;
+ argc--;
+ argv++;
+
+ if (argc == 0)
+ {
if (mode != mode_create)
{
mu_error (_("database name not given"));
@@ -1631,6 +1633,18 @@ mutool_dbm (int argc, char **argv)
switch (mode)
{
case mode_list:
+ if (!format)
+ format = DEFAULT_LIST_FORMAT;
+ if (suppress_header == -1)
+ suppress_header = 1;
+ list_database (argc, argv);
+ break;
+
+ case mode_dump:
+ if (!format)
+ format = DEFAULT_DUMP_FORMAT;
+ if (suppress_header == -1)
+ suppress_header = 0;
list_database (argc, argv);
break;
diff --git a/mu/help.c b/mu/help.c
index 3162481..d3b6e3a 100644
--- a/mu/help.c
+++ b/mu/help.c
@@ -21,6 +21,7 @@
#endif
#include <stdlib.h>
#include <mailutils/nls.h>
+#include <mailutils/io.h>
#include "mailutils/libargp.h"
#include "mu.h"
@@ -54,7 +55,7 @@ mutool_help (int argc, char **argv)
mu_error (_("don't know what %s is"), argv[index]);
exit (1);
}
- argv[0] = argv[index];
+ mu_asprintf (&argv[0], "%s %s", mu_program_name, argv[index]);
argv[1] = "--help";
return action (2, argv);
}
diff --git a/mu/mu.c b/mu/mu.c
index 01674e2..19681d7 100644
--- a/mu/mu.c
+++ b/mu/mu.c
@@ -135,6 +135,10 @@ main (int argc, char **argv)
/* Disable --version option in action. */
argp_program_version = NULL;
argp_program_version_hook = NULL;
+
+ /* Reset argv[0] for diagnostic purposes */
+ mu_asprintf (&argv[0], "%s %s", mu_program_name, argv[0]);
+
/* Run the action. */
exit (action (argc, argv));
}
hooks/post-receive
--
GNU Mailutils
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [SCM] GNU Mailutils branch, master, updated. release-2.2-418-gfc93493,
Sergey Poznyakoff <=