Fix command help for unexpected options (#7476)

This commit is contained in:
WuYunlong 2020-07-15 17:38:22 +08:00 committed by GitHub
parent 7da8c062d5
commit e5166eccee
6 changed files with 20 additions and 3 deletions

View File

@ -1911,7 +1911,7 @@ void aclCommand(client *c) {
addReplyBulkCString(c,"client-info"); addReplyBulkCString(c,"client-info");
addReplyBulkCBuffer(c,le->cinfo,sdslen(le->cinfo)); addReplyBulkCBuffer(c,le->cinfo,sdslen(le->cinfo));
} }
} else if (!strcasecmp(sub,"help")) { } else if (c->argc == 2 && !strcasecmp(sub,"help")) {
const char *help[] = { const char *help[] = {
"LOAD -- Reload users from the ACL file.", "LOAD -- Reload users from the ACL file.",
"SAVE -- Save the current config to the ACL file.", "SAVE -- Save the current config to the ACL file.",

View File

@ -621,7 +621,7 @@ NULL
resets += latencyResetEvent(c->argv[j]->ptr); resets += latencyResetEvent(c->argv[j]->ptr);
addReplyLongLong(c,resets); addReplyLongLong(c,resets);
} }
} else if (!strcasecmp(c->argv[1]->ptr,"help") && c->argc >= 2) { } else if (!strcasecmp(c->argv[1]->ptr,"help") && c->argc == 2) {
addReplyHelp(c, help); addReplyHelp(c, help);
} else { } else {
addReplySubcommandSyntaxError(c); addReplySubcommandSyntaxError(c);

View File

@ -1885,7 +1885,7 @@ NULL
server.dirty++; server.dirty++;
notifyKeyspaceEvent(NOTIFY_STREAM,"xgroup-delconsumer", notifyKeyspaceEvent(NOTIFY_STREAM,"xgroup-delconsumer",
c->argv[2],c->db->id); c->argv[2],c->db->id);
} else if (!strcasecmp(opt,"HELP")) { } else if (c->argc == 2 && !strcasecmp(opt,"HELP")) {
addReplyHelp(c, help); addReplyHelp(c, help);
} else { } else {
addReplySubcommandSyntaxError(c); addReplySubcommandSyntaxError(c);

View File

@ -255,4 +255,9 @@ start_server {tags {"acl"}} {
r ACL setuser default on r ACL setuser default on
set e set e
} {*NOAUTH*} } {*NOAUTH*}
test {ACL HELP should not have unexpected options} {
catch {r ACL help xxx} e
assert_match "*Unknown subcommand or wrong number of arguments*" $e
}
} }

View File

@ -67,4 +67,9 @@ start_server {tags {"latency-monitor"}} {
} }
assert_match {*expire-cycle*} [r latency latest] assert_match {*expire-cycle*} [r latency latest]
} }
test {LATENCY HELP should not have unexpected options} {
catch {r LATENCY help xxx} e
assert_match "*Unknown subcommand or wrong number of arguments*" $e
}
} }

View File

@ -461,3 +461,10 @@ start_server {tags {"stream"} overrides {appendonly yes aof-use-rdb-preamble no}
assert {[dict get [r xinfo stream mystream] last-generated-id] == "2-2"} assert {[dict get [r xinfo stream mystream] last-generated-id] == "2-2"}
} }
} }
start_server {tags {"stream"}} {
test {XGROUP HELP should not have unexpected options} {
catch {r XGROUP help xxx} e
assert_match "*Unknown subcommand or wrong number of arguments*" $e
}
}