From: Karl Fleischmann Date: Thu, 22 Jun 2023 10:16:08 +0000 (+0200) Subject: doveadm: Enable setting the output stream and return code to print usage X-Git-Tag: 2.4.0~2644 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c08bcd941d80d12b6362249cb336a73124ff5405;p=thirdparty%2Fdovecot%2Fcore.git doveadm: Enable setting the output stream and return code to print usage This commit prepares doveadm subcommands from printing the usage string to stdout when requested with "--help". --- diff --git a/src/doveadm/doveadm.c b/src/doveadm/doveadm.c index ead2e1a94a..30e8c25f36 100644 --- a/src/doveadm/doveadm.c +++ b/src/doveadm/doveadm.c @@ -137,10 +137,16 @@ void usage(void) usage_prefix(stderr, "", EX_USAGE); } +static void ATTR_NORETURN +print_usage_and_exit(FILE *out, const struct doveadm_cmd_ver2 *cmd, int exit_code) +{ + fprintf(out, "doveadm %s %s\n", cmd->name, cmd->usage); + lib_exit(exit_code); +} + void help_ver2(const struct doveadm_cmd_ver2 *cmd) { - fprintf(stderr, "doveadm %s %s\n", cmd->name, cmd->usage); - lib_exit(EX_USAGE); + print_usage_and_exit(stderr, cmd, EX_USAGE); } static void cmd_help(struct doveadm_cmd_context *cctx)