From: Timo Sirainen Date: Mon, 22 Feb 2016 20:10:42 +0000 (+0200) Subject: doveadm: Fixed usage printing for ver2 commands X-Git-Tag: 2.2.22.rc1~89 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=bef3447d29acf374bbae54bc7d6bba2583c6d5ea;p=thirdparty%2Fdovecot%2Fcore.git doveadm: Fixed usage printing for ver2 commands --- diff --git a/src/doveadm/doveadm-mail.c b/src/doveadm/doveadm-mail.c index e8767c5b1f..e58a1551e2 100644 --- a/src/doveadm/doveadm-mail.c +++ b/src/doveadm/doveadm-mail.c @@ -782,8 +782,13 @@ void doveadm_mail_help(const struct doveadm_mail_cmd *cmd) void doveadm_mail_try_help_name(const char *cmd_name) { + const struct doveadm_cmd_ver2 *cmd2; const struct doveadm_mail_cmd *cmd; + cmd2 = doveadm_cmd_find_ver2(cmd_name); + if (cmd2 != NULL) + help_ver2(cmd2); + cmd = doveadm_mail_cmd_find(cmd_name); if (cmd != NULL) doveadm_mail_help(cmd); diff --git a/src/doveadm/doveadm.c b/src/doveadm/doveadm.c index a75984680d..b85d58d46c 100644 --- a/src/doveadm/doveadm.c +++ b/src/doveadm/doveadm.c @@ -110,6 +110,7 @@ doveadm_usage_compress_lines(FILE *out, const char *str, const char *prefix) static void ATTR_NORETURN usage_to(FILE *out, const char *prefix) { + const struct doveadm_cmd_ver2 *cmd2; const struct doveadm_cmd *cmd; string_t *str = t_str_new(1024); @@ -120,6 +121,8 @@ usage_to(FILE *out, const char *prefix) array_foreach(&doveadm_cmds, cmd) str_printfa(str, "%s\t%s\n", cmd->name, cmd->short_usage); + array_foreach(&doveadm_cmds_ver2, cmd2) + str_printfa(str, "%s\t%s\n", cmd2->name, cmd2->usage); doveadm_mail_usage(str); doveadm_usage_compress_lines(out, str_c(str), prefix); @@ -219,6 +222,7 @@ static bool doveadm_try_run(const char *cmd_name, int argc, char *argv[]) static bool doveadm_has_subcommands(const char *cmd_name) { + const struct doveadm_cmd_ver2 *cmd2; const struct doveadm_cmd *cmd; unsigned int len = strlen(cmd_name); @@ -227,6 +231,11 @@ static bool doveadm_has_subcommands(const char *cmd_name) cmd->name[len] == ' ') return TRUE; } + array_foreach(&doveadm_cmds_ver2, cmd2) { + if (strncmp(cmd2->name, cmd_name, len) == 0 && + cmd2->name[len] == ' ') + return TRUE; + } return doveadm_mail_has_subcommands(cmd_name); }