dovecot-2.0: doveadm help: Fixed to work with multi-word commands.

dovecot at dovecot.org dovecot at dovecot.org
Wed May 12 17:45:52 EEST 2010


details:   http://hg.dovecot.org/dovecot-2.0/rev/bc0b336efef7
changeset: 11286:bc0b336efef7
user:      Timo Sirainen <tss at iki.fi>
date:      Wed May 12 16:45:40 2010 +0200
description:
doveadm help: Fixed to work with multi-word commands.

diffstat:

 src/doveadm/doveadm-mail.c |   7 ++++++-
 src/doveadm/doveadm-mail.h |   1 +
 src/doveadm/doveadm.c      |  21 ++++++++++++++++-----
 3 files changed, 23 insertions(+), 6 deletions(-)

diffs (79 lines):

diff -r 1a3c9bd45b11 -r bc0b336efef7 src/doveadm/doveadm-mail.c
--- a/src/doveadm/doveadm-mail.c	Wed May 12 16:40:22 2010 +0200
+++ b/src/doveadm/doveadm-mail.c	Wed May 12 16:45:40 2010 +0200
@@ -406,7 +406,7 @@
 	exit(0);
 }
 
-void doveadm_mail_help_name(const char *cmd_name)
+void doveadm_mail_try_help_name(const char *cmd_name)
 {
 	const struct doveadm_mail_cmd *cmd;
 
@@ -414,6 +414,11 @@
 		if (strcmp(cmd->name, cmd_name) == 0)
 			doveadm_mail_help(cmd);
 	}
+}
+
+void doveadm_mail_help_name(const char *cmd_name)
+{
+	doveadm_mail_try_help_name(cmd_name);
 	i_fatal("Missing help for command %s", cmd_name);
 }
 
diff -r 1a3c9bd45b11 -r bc0b336efef7 src/doveadm/doveadm-mail.h
--- a/src/doveadm/doveadm-mail.h	Wed May 12 16:40:22 2010 +0200
+++ b/src/doveadm/doveadm-mail.h	Wed May 12 16:45:40 2010 +0200
@@ -30,6 +30,7 @@
 void doveadm_mail_usage(void);
 void doveadm_mail_help(const struct doveadm_mail_cmd *cmd) ATTR_NORETURN;
 void doveadm_mail_help_name(const char *cmd_name) ATTR_NORETURN;
+void doveadm_mail_try_help_name(const char *cmd_name);
 
 void doveadm_mail_init(void);
 void doveadm_mail_deinit(void);
diff -r 1a3c9bd45b11 -r bc0b336efef7 src/doveadm/doveadm.c
--- a/src/doveadm/doveadm.c	Wed May 12 16:40:22 2010 +0200
+++ b/src/doveadm/doveadm.c	Wed May 12 16:45:40 2010 +0200
@@ -2,6 +2,7 @@
 
 #include "lib.h"
 #include "array.h"
+#include "str.h"
 #include "module-dir.h"
 #include "master-service.h"
 #include "master-service-settings.h"
@@ -56,17 +57,27 @@
 	return buf;
 }
 
-static void cmd_help(int argc ATTR_UNUSED, char *argv[])
+static void cmd_help(int argc, char *argv[])
 {
 	const struct doveadm_cmd *cmd;
+	string_t *name;
+	int i;
 
 	if (argv[1] == NULL)
 		usage();
-	array_foreach(&doveadm_cmds, cmd) {
-		if (strcmp(cmd->name, argv[1]) == 0)
-			help(cmd);
+
+	name = t_str_new(100);
+	for (i = 1; i < argc; i++) {
+		str_append(name, argv[i]);
+
+		array_foreach(&doveadm_cmds, cmd) {
+			if (strcmp(cmd->name, str_c(name)) == 0)
+				help(cmd);
+		}
+		doveadm_mail_try_help_name(str_c(name));
+
+		str_append_c(name, ' ');
 	}
-	doveadm_mail_help_name(argv[1]);
 	usage();
 }
 


More information about the dovecot-cvs mailing list