summaryrefslogtreecommitdiff
path: root/src/slowlog.c
diff options
context:
space:
mode:
authorItamar Haber <itamar@redislabs.com>2017-11-27 17:57:44 +0200
committerItamar Haber <itamar@redislabs.com>2017-11-28 21:15:45 +0200
commit59d52f7fabb48c3a6ebaac869ce3d6e5f3dc704f (patch)
treeda2f0adacc6c494f372ecf11f8566d20db79a05f /src/slowlog.c
parent29252391c4856e500277bcd84ae0f57b8e6ca661 (diff)
downloadredis-59d52f7fabb48c3a6ebaac869ce3d6e5f3dc704f.tar.gz
Standardizes the 'help' subcommand
This adds a new `addReplyHelp` helper that's used by commands when returning a help text. The following commands have been touched: DEBUG, OBJECT, COMMAND, PUBSUB, SCRIPT and SLOWLOG. WIP Fix entry command table entry for OBJECT for HELP option. After #4472 the command may have just 2 arguments. Improve OBJECT HELP descriptions. See #4472. WIP 2 WIP 3
Diffstat (limited to 'src/slowlog.c')
-rw-r--r--src/slowlog.c15
1 files changed, 12 insertions, 3 deletions
diff --git a/src/slowlog.c b/src/slowlog.c
index 32ec4374c..9d6f4f02d 100644
--- a/src/slowlog.c
+++ b/src/slowlog.c
@@ -140,7 +140,15 @@ void slowlogReset(void) {
/* The SLOWLOG command. Implements all the subcommands needed to handle the
* Redis slow log. */
void slowlogCommand(client *c) {
- if (c->argc == 2 && !strcasecmp(c->argv[1]->ptr,"reset")) {
+ if (!strcasecmp(c->argv[1]->ptr,"help") && c->argc == 2) {
+ const char *help[] = {
+ "get [count] -- Return the top entries from the slowlog (default: 10).",
+ "len -- Return the length of the slowlog.",
+ "reset -- Reset the slowlog.",
+ NULL
+ };
+ addReplyHelp(c, help);
+ } else if (c->argc == 2 && !strcasecmp(c->argv[1]->ptr,"reset")) {
slowlogReset();
addReply(c,shared.ok);
} else if (c->argc == 2 && !strcasecmp(c->argv[1]->ptr,"len")) {
@@ -177,7 +185,8 @@ void slowlogCommand(client *c) {
}
setDeferredMultiBulkLength(c,totentries,sent);
} else {
- addReplyError(c,
- "Unknown SLOWLOG subcommand or wrong # of args. Try GET, RESET, LEN.");
+ addReplyErrorFormat(c, "Unknown subcommand or wrong number of arguments for '%s'. Try SLOWLOG help",
+ (char*)c->argv[1]->ptr);
+ return;
}
}