Make redis-cli --cluster help output to stdout (#10485)

redis-cli --cluster help currently outputs the help on stderr.
This is similar to #9124
This commit is contained in:
Binbin 2022-03-28 19:47:36 +08:00 committed by GitHub
parent 63f77698cf
commit 3f28d7d712
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 14 additions and 14 deletions

View File

@ -7323,14 +7323,14 @@ static int clusterManagerCommandHelp(int argc, char **argv) {
int commands_count = sizeof(clusterManagerCommands) / int commands_count = sizeof(clusterManagerCommands) /
sizeof(clusterManagerCommandDef); sizeof(clusterManagerCommandDef);
int i = 0, j; int i = 0, j;
fprintf(stderr, "Cluster Manager Commands:\n"); fprintf(stdout, "Cluster Manager Commands:\n");
int padding = 15; int padding = 15;
for (; i < commands_count; i++) { for (; i < commands_count; i++) {
clusterManagerCommandDef *def = &(clusterManagerCommands[i]); clusterManagerCommandDef *def = &(clusterManagerCommands[i]);
int namelen = strlen(def->name), padlen = padding - namelen; int namelen = strlen(def->name), padlen = padding - namelen;
fprintf(stderr, " %s", def->name); fprintf(stdout, " %s", def->name);
for (j = 0; j < padlen; j++) fprintf(stderr, " "); for (j = 0; j < padlen; j++) fprintf(stdout, " ");
fprintf(stderr, "%s\n", (def->args ? def->args : "")); fprintf(stdout, "%s\n", (def->args ? def->args : ""));
if (def->options != NULL) { if (def->options != NULL) {
int optslen = strlen(def->options); int optslen = strlen(def->options);
char *p = def->options, *eos = p + optslen; char *p = def->options, *eos = p + optslen;
@ -7340,18 +7340,18 @@ static int clusterManagerCommandHelp(int argc, char **argv) {
char buf[255]; char buf[255];
memcpy(buf, p, deflen); memcpy(buf, p, deflen);
buf[deflen] = '\0'; buf[deflen] = '\0';
for (j = 0; j < padding; j++) fprintf(stderr, " "); for (j = 0; j < padding; j++) fprintf(stdout, " ");
fprintf(stderr, " --cluster-%s\n", buf); fprintf(stdout, " --cluster-%s\n", buf);
p = comma + 1; p = comma + 1;
if (p >= eos) break; if (p >= eos) break;
} }
if (p < eos) { if (p < eos) {
for (j = 0; j < padding; j++) fprintf(stderr, " "); for (j = 0; j < padding; j++) fprintf(stdout, " ");
fprintf(stderr, " --cluster-%s\n", p); fprintf(stdout, " --cluster-%s\n", p);
} }
} }
} }
fprintf(stderr, "\nFor check, fix, reshard, del-node, set-timeout, " fprintf(stdout, "\nFor check, fix, reshard, del-node, set-timeout, "
"info, rebalance, call, import, backup you " "info, rebalance, call, import, backup you "
"can specify the host and port of any working node in " "can specify the host and port of any working node in "
"the cluster.\n"); "the cluster.\n");
@ -7359,16 +7359,16 @@ static int clusterManagerCommandHelp(int argc, char **argv) {
int options_count = sizeof(clusterManagerOptions) / int options_count = sizeof(clusterManagerOptions) /
sizeof(clusterManagerOptionDef); sizeof(clusterManagerOptionDef);
i = 0; i = 0;
fprintf(stderr, "\nCluster Manager Options:\n"); fprintf(stdout, "\nCluster Manager Options:\n");
for (; i < options_count; i++) { for (; i < options_count; i++) {
clusterManagerOptionDef *def = &(clusterManagerOptions[i]); clusterManagerOptionDef *def = &(clusterManagerOptions[i]);
int namelen = strlen(def->name), padlen = padding - namelen; int namelen = strlen(def->name), padlen = padding - namelen;
fprintf(stderr, " %s", def->name); fprintf(stdout, " %s", def->name);
for (j = 0; j < padlen; j++) fprintf(stderr, " "); for (j = 0; j < padlen; j++) fprintf(stdout, " ");
fprintf(stderr, "%s\n", def->desc); fprintf(stdout, "%s\n", def->desc);
} }
fprintf(stderr, "\n"); fprintf(stdout, "\n");
return 0; return 0;
} }