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
This commit is contained in:
Itamar Haber
2017-11-27 17:57:44 +02:00
parent 29252391c4
commit 59d52f7fab
8 changed files with 112 additions and 69 deletions

View File

@ -1430,7 +1430,17 @@ void evalShaCommand(client *c) {
}
void scriptCommand(client *c) {
if (c->argc == 2 && !strcasecmp(c->argv[1]->ptr,"flush")) {
if (c->argc == 2 && !strcasecmp(c->argv[1]->ptr,"help")) {
const char *help[] = {
"debug (yes|sync|no) -- Set the debug mode for subsequent scripts executed.",
"exists sha1 [sha1 ...] -- Return information about the existence of the scripts in the script cache.",
"flush -- Flush the Lua scripts cache.",
"kill -- Kill the currently executing Lua script.",
"load script -- Load a script into the scripts cache, without executing it.",
NULL
};
addReplyHelp(c, help);
} else if (c->argc == 2 && !strcasecmp(c->argv[1]->ptr,"flush")) {
scriptingReset();
addReply(c,shared.ok);
replicationScriptCacheFlush();
@ -1489,9 +1499,12 @@ void scriptCommand(client *c) {
c->flags |= CLIENT_LUA_DEBUG_SYNC;
} else {
addReplyError(c,"Use SCRIPT DEBUG yes/sync/no");
return;
}
} else {
addReplyError(c, "Unknown SCRIPT subcommand or wrong # of args.");
addReplyErrorFormat(c, "Unknown subcommand or wrong number of arguments for '%s'. Try SCRIPT help",
(char*)c->argv[1]->ptr);
return;
}
}