dovecot-2.0: doveadm help: Show man pages instead of small usage...

dovecot at dovecot.org dovecot at dovecot.org
Wed Jun 30 19:30:37 EEST 2010


details:   http://hg.dovecot.org/dovecot-2.0/rev/b07bb05789cf
changeset: 11660:b07bb05789cf
user:      Timo Sirainen <tss at iki.fi>
date:      Wed Jun 30 17:30:34 2010 +0100
description:
doveadm help: Show man pages instead of small usage strings.

diffstat:

 src/doveadm/Makefile.am |   3 ++-
 src/doveadm/doveadm.c   |  32 +++++++++-----------------------
 2 files changed, 11 insertions(+), 24 deletions(-)

diffs (67 lines):

diff -r 3156315704ef -r b07bb05789cf src/doveadm/Makefile.am
--- a/src/doveadm/Makefile.am	Tue Jun 29 20:26:04 2010 +0100
+++ b/src/doveadm/Makefile.am	Wed Jun 30 17:30:34 2010 +0100
@@ -15,7 +15,8 @@
 	-I$(top_srcdir)/src/auth \
 	-DMODULEDIR=\""$(moduledir)"\" \
 	-DDOVEADM_MODULEDIR=\""$(doveadm_moduledir)"\" \
-	-DPKG_RUNDIR=\""$(rundir)"\"
+	-DPKG_RUNDIR=\""$(rundir)"\" \
+	-DMANDIR=\""$(mandir)"\"
 
 if !BUILD_SHARED_LIBS
 unused_objects = \
diff -r 3156315704ef -r b07bb05789cf src/doveadm/doveadm.c
--- a/src/doveadm/doveadm.c	Tue Jun 29 20:26:04 2010 +0100
+++ b/src/doveadm/doveadm.c	Wed Jun 30 17:30:34 2010 +0100
@@ -3,6 +3,8 @@
 #include "lib.h"
 #include "array.h"
 #include "str.h"
+#include "env-util.h"
+#include "execv-const.h"
 #include "module-dir.h"
 #include "master-service.h"
 #include "master-service-settings.h"
@@ -159,34 +161,18 @@
 	return doveadm_mail_has_subcommands(cmd_name);
 }
 
-static void cmd_help(int argc, char *argv[])
+static void cmd_help(int argc ATTR_UNUSED, char *argv[])
 {
-	const struct doveadm_cmd *cmd;
-	string_t *name;
-	int i;
+	const char *man_argv[3];
 
 	if (argv[1] == NULL)
 		usage_to(stdout, "");
 
-	/* try to find exact command */
-	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_to(cmd, stdout);
-		}
-		doveadm_mail_try_help_name(str_c(name));
-
-		str_append_c(name, ' ');
-	}
-
-	/* see if there are subcommands we can list */
-	if (doveadm_has_subcommands(argv[1]))
-		usage_to(stdout, argv[1]);
-
-	usage_to(stdout, "");
+	env_put("MANPATH="MANDIR);
+	man_argv[0] = "man";
+	man_argv[1] = t_strconcat("doveadm-", argv[1], NULL);
+	man_argv[2] = NULL;
+	execvp_const(man_argv[0], man_argv);
 }
 
 static struct doveadm_cmd doveadm_cmd_help = {


More information about the dovecot-cvs mailing list