dovecot-2.0: doveadm help and without parameters now writes outp...

dovecot at dovecot.org dovecot at dovecot.org
Fri May 28 17:24:59 EEST 2010


details:   http://hg.dovecot.org/dovecot-2.0/rev/c3f1a15f50ca
changeset: 11419:c3f1a15f50ca
user:      Timo Sirainen <tss at iki.fi>
date:      Fri May 28 15:24:55 2010 +0100
description:
doveadm help and without parameters now writes output to stdout, otherwise stderr.

diffstat:

 src/doveadm/doveadm-mail.c |   8 ++++----
 src/doveadm/doveadm-mail.h |   3 ++-
 src/doveadm/doveadm.c      |  20 +++++++++++++-------
 3 files changed, 19 insertions(+), 12 deletions(-)

diffs (104 lines):

diff -r 8f63f17fdb0c -r c3f1a15f50ca src/doveadm/doveadm-mail.c
--- a/src/doveadm/doveadm-mail.c	Fri May 28 15:20:19 2010 +0100
+++ b/src/doveadm/doveadm-mail.c	Fri May 28 15:24:55 2010 +0100
@@ -446,15 +446,15 @@
 	array_append(&doveadm_mail_cmds, cmd, 1);
 }
 
-void doveadm_mail_usage(void)
+void doveadm_mail_usage(FILE *out)
 {
 	const struct doveadm_mail_cmd *cmd;
 
 	array_foreach(&doveadm_mail_cmds, cmd) {
-		fprintf(stderr, USAGE_CMDNAME_FMT" [-u <user>|-A]", cmd->name);
+		fprintf(out, USAGE_CMDNAME_FMT" [-u <user>|-A]", cmd->name);
 		if (cmd->usage_args != NULL)
-			fprintf(stderr, " %s", cmd->usage_args);
-		fputc('\n', stderr);
+			fprintf(out, " %s", cmd->usage_args);
+		fputc('\n', out);
 	}
 }
 
diff -r 8f63f17fdb0c -r c3f1a15f50ca src/doveadm/doveadm-mail.h
--- a/src/doveadm/doveadm-mail.h	Fri May 28 15:20:19 2010 +0100
+++ b/src/doveadm/doveadm-mail.h	Fri May 28 15:24:55 2010 +0100
@@ -1,6 +1,7 @@
 #ifndef DOVEADM_MAIL_H
 #define DOVEADM_MAIL_H
 
+#include <stdio.h>
 #include "doveadm.h"
 #include "module-context.h"
 
@@ -56,7 +57,7 @@
 bool doveadm_mail_try_run(const char *cmd_name, int argc, char *argv[]);
 void doveadm_mail_register_cmd(const struct doveadm_mail_cmd *cmd);
 
-void doveadm_mail_usage(void);
+void doveadm_mail_usage(FILE *out);
 void doveadm_mail_help(const struct doveadm_mail_cmd *cmd) ATTR_NORETURN;
 void doveadm_mail_help_name(const char *cmd_name) ATTR_NORETURN;
 void doveadm_mail_try_help_name(const char *cmd_name);
diff -r 8f63f17fdb0c -r c3f1a15f50ca src/doveadm/doveadm.c
--- a/src/doveadm/doveadm.c	Fri May 28 15:20:19 2010 +0100
+++ b/src/doveadm/doveadm.c	Fri May 28 15:24:55 2010 +0100
@@ -25,20 +25,26 @@
 	array_append(&doveadm_cmds, cmd, 1);
 }
 
-void usage(void)
+static void ATTR_NORETURN
+usage_to(FILE *out)
 {
 	const struct doveadm_cmd *cmd;
 
-	fprintf(stderr, "usage: doveadm [-Dv] <command> [<args>]\n");
+	fprintf(out, "usage: doveadm [-Dv] <command> [<args>]\n");
 
 	array_foreach(&doveadm_cmds, cmd) {
-		fprintf(stderr, USAGE_CMDNAME_FMT" %s\n",
+		fprintf(out, USAGE_CMDNAME_FMT" %s\n",
 			cmd->name, cmd->short_usage);
 	}
-	doveadm_mail_usage();
+	doveadm_mail_usage(out);
 	exit(1);
 }
 
+void usage(void)
+{
+	usage_to(stderr);
+}
+
 void help(const struct doveadm_cmd *cmd)
 {
 	fprintf(stderr, "doveadm %s %s\n", cmd->name, cmd->short_usage);
@@ -80,7 +86,7 @@
 	int i;
 
 	if (argv[1] == NULL)
-		usage();
+		usage_to(stdout);
 
 	name = t_str_new(100);
 	for (i = 1; i < argc; i++) {
@@ -94,7 +100,7 @@
 
 		str_append_c(name, ' ');
 	}
-	usage();
+	usage_to(stdout);
 }
 
 static struct doveadm_cmd doveadm_cmd_help = {
@@ -239,7 +245,7 @@
 	doveadm_load_modules();
 
 	if (optind == argc)
-		usage();
+		usage_to(stdout);
 
 	cmd_name = argv[optind];
 	argc -= optind;


More information about the dovecot-cvs mailing list