]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
doveadm: Enable setting the output stream and return code to print usage
authorKarl Fleischmann <karl.fleischmann@open-xchange.com>
Thu, 22 Jun 2023 10:16:08 +0000 (12:16 +0200)
committerKarl Fleischmann <karl.fleischmann@open-xchange.com>
Mon, 10 Jul 2023 10:10:42 +0000 (12:10 +0200)
This commit prepares doveadm subcommands from printing the usage string
to stdout when requested with "--help".

src/doveadm/doveadm.c

index ead2e1a94a30f4159c9d4b80113b7d7b0247893d..30e8c25f36e567284447af857c06e2c6f5bab05a 100644 (file)
@@ -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)