]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
doveadm help: Show man pages instead of small usage strings.
authorTimo Sirainen <tss@iki.fi>
Wed, 30 Jun 2010 16:30:34 +0000 (17:30 +0100)
committerTimo Sirainen <tss@iki.fi>
Wed, 30 Jun 2010 16:30:34 +0000 (17:30 +0100)
--HG--
branch : HEAD

src/doveadm/Makefile.am
src/doveadm/doveadm.c

index 805a369c54311e7ca845c4503a32c8a0796788a1..5ee9893a1180bb3b0c72455011fd4190bf14ef8a 100644 (file)
@@ -15,7 +15,8 @@ AM_CPPFLAGS = \
        -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 = \
index 76d9a474c9814346431efc1084eba8d554b558fa..8a5f46229fdfc3b6fcf66edb6bf0a80fce82c945 100644 (file)
@@ -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 @@ static bool doveadm_has_subcommands(const char *cmd_name)
        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 = {