dovecot-2.0: doveadm: Mail commands now take username as -u para...

dovecot at dovecot.org dovecot at dovecot.org
Wed Apr 7 02:46:15 EEST 2010


details:   http://hg.dovecot.org/dovecot-2.0/rev/e0fe42c6424b
changeset: 11091:e0fe42c6424b
user:      Timo Sirainen <tss at iki.fi>
date:      Wed Apr 07 02:46:11 2010 +0300
description:
doveadm: Mail commands now take username as -u parameter and all with -A.
If -u or -a isn't given, use the current user's settings (without userdb
lookup).

diffstat:

 src/doveadm/doveadm-mail.c |  24 ++++++++++++++----------
 1 files changed, 14 insertions(+), 10 deletions(-)

diffs (60 lines):

diff -r 6973977bf626 -r e0fe42c6424b src/doveadm/doveadm-mail.c
--- a/src/doveadm/doveadm-mail.c	Wed Apr 07 02:43:55 2010 +0300
+++ b/src/doveadm/doveadm-mail.c	Wed Apr 07 02:46:11 2010 +0300
@@ -218,26 +218,30 @@
 	if (doveadm_debug)
 		service_flags |= MAIL_STORAGE_SERVICE_FLAG_DEBUG;
 
-	while ((c = getopt(argc, argv, "a")) > 0) {
+	username = getenv("USER");
+	while ((c = getopt(argc, argv, "Au:")) > 0) {
 		switch (c) {
-		case 'a':
+		case 'A':
 			all_users = TRUE;
 			break;
+		case 'u':
+			service_flags |=
+				MAIL_STORAGE_SERVICE_FLAG_USERDB_LOOKUP;
+			username = optarg;
+			break;
 		default:
 			doveadm_mail_help(cmd);
 		}
 	}
+	argv += optind;
+
 	if (!all_users) {
-		if (optind == argc)
-			doveadm_mail_help(cmd);
-		service_flags |= MAIL_STORAGE_SERVICE_FLAG_USERDB_LOOKUP;
-		username = argv[optind++];
 		doveadm_mail_single_user(cmd->cmd, username, service_flags,
-					 (const char **)argv + optind);
+					 (const char **)argv);
 	} else {
 		service_flags |= MAIL_STORAGE_SERVICE_FLAG_TEMP_PRIV_DROP;
 		doveadm_mail_all_users(cmd->cmd, service_flags,
-				       (const char **)argv + optind);
+				       (const char **)argv);
 	}
 }
 
@@ -265,7 +269,7 @@
 	const struct doveadm_mail_cmd *cmd;
 
 	array_foreach(&doveadm_mail_cmds, cmd) {
-		fprintf(stderr, USAGE_CMDNAME_FMT" <user>|-a", cmd->name);
+		fprintf(stderr, USAGE_CMDNAME_FMT" [-u <user>|-A]", cmd->name);
 		if (cmd->usage_args != NULL)
 			fprintf(stderr, " %s", cmd->usage_args);
 		fputc('\n', stderr);
@@ -274,7 +278,7 @@
 
 void doveadm_mail_help(const struct doveadm_mail_cmd *cmd)
 {
-	fprintf(stderr, "doveadm %s <user>|-a %s\n", cmd->name,
+	fprintf(stderr, "doveadm %s [-u <user>|-A] %s\n", cmd->name,
 		cmd->usage_args == NULL ? "" : cmd->usage_args);
 	exit(0);
 }


More information about the dovecot-cvs mailing list