Commit 51eb6cb3 authored by Itamar Haber's avatar Itamar Haber
Browse files

Adds help to `CONFIG`

parent bd5af03d
...@@ -2065,19 +2065,24 @@ void configCommand(client *c) { ...@@ -2065,19 +2065,24 @@ void configCommand(client *c) {
return; return;
} }
if (!strcasecmp(c->argv[1]->ptr,"set")) { if (c->argc == 2 && !strcasecmp(c->argv[1]->ptr,"help")) {
if (c->argc != 4) goto badarity; const char *help[] = {
"get <pattern> -- Return parameters matching the glob-like <pattern> and their values.",
"set <parameter> <value> -- Set parameter to value.",
"resetstat -- Reset statistics reported by INFO.",
"rewrite -- Rewrite the configuration file.",
NULL
};
addReplyHelp(c, help);
} else if (!strcasecmp(c->argv[1]->ptr,"set") && c->argc == 4) {
configSetCommand(c); configSetCommand(c);
} else if (!strcasecmp(c->argv[1]->ptr,"get")) { } else if (!strcasecmp(c->argv[1]->ptr,"get") && c->argc == 3) {
if (c->argc != 3) goto badarity;
configGetCommand(c); configGetCommand(c);
} else if (!strcasecmp(c->argv[1]->ptr,"resetstat")) { } else if (!strcasecmp(c->argv[1]->ptr,"resetstat") && c->argc == 2) {
if (c->argc != 2) goto badarity;
resetServerStats(); resetServerStats();
resetCommandTableStats(); resetCommandTableStats();
addReply(c,shared.ok); addReply(c,shared.ok);
} else if (!strcasecmp(c->argv[1]->ptr,"rewrite")) { } else if (!strcasecmp(c->argv[1]->ptr,"rewrite") && c->argc == 2) {
if (c->argc != 2) goto badarity;
if (server.configfile == NULL) { if (server.configfile == NULL) {
addReplyError(c,"The server is running without a config file"); addReplyError(c,"The server is running without a config file");
return; return;
...@@ -2090,12 +2095,8 @@ void configCommand(client *c) { ...@@ -2090,12 +2095,8 @@ void configCommand(client *c) {
addReply(c,shared.ok); addReply(c,shared.ok);
} }
} else { } else {
addReplyError(c, addReplyErrorFormat(c, "Unknown subcommand or wrong number of arguments for '%s'. Try SLOWLOG help",
"CONFIG subcommand must be one of GET, SET, RESETSTAT, REWRITE"); (char*)c->argv[1]->ptr);
return;
} }
return;
badarity:
addReplyErrorFormat(c,"Wrong number of arguments for CONFIG %s",
(char*) c->argv[1]->ptr);
} }
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment