mirror of
https://codeberg.org/redict/redict.git
synced 2025-01-22 08:08:53 -05:00
Adds MODULE HELP and implements addReplySubSyntaxError
This commit is contained in:
parent
f847dd3ad8
commit
76ad23d012
13
src/module.c
13
src/module.c
@ -4499,7 +4499,15 @@ int moduleUnload(sds name) {
|
||||
* MODULE LOAD <path> [args...] */
|
||||
void moduleCommand(client *c) {
|
||||
char *subcmd = c->argv[1]->ptr;
|
||||
|
||||
if (c->argc == 2 && !strcasecmp(subcmd,"help")) {
|
||||
const char *help[] = {
|
||||
"list -- Return a list of loaded modules.",
|
||||
"load <path> [arg ...] -- Load a module library from <path>.",
|
||||
"unload <name> -- Unload a module.",
|
||||
NULL
|
||||
};
|
||||
addReplyHelp(c, help);
|
||||
} else
|
||||
if (!strcasecmp(subcmd,"load") && c->argc >= 3) {
|
||||
robj **argv = NULL;
|
||||
int argc = 0;
|
||||
@ -4548,7 +4556,8 @@ void moduleCommand(client *c) {
|
||||
}
|
||||
dictReleaseIterator(di);
|
||||
} else {
|
||||
addReply(c,shared.syntaxerr);
|
||||
addReplySubSyntaxError(c);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -560,6 +560,18 @@ void addReplyHelp(client *c, const char **help) {
|
||||
setDeferredMultiBulkLength(c,blenp,blen);
|
||||
}
|
||||
|
||||
/* Add a suggestive error reply.
|
||||
* This function is typically invoked by from commands that support
|
||||
* subcommands in response to an unknown subcommand or argument error. */
|
||||
void addReplySubSyntaxError(client *c) {
|
||||
sds cmd = sdsnew((char*) c->argv[0]->ptr);
|
||||
sdstoupper(cmd);
|
||||
addReplyErrorFormat(c,
|
||||
"Unknown subcommand or wrong number of arguments for '%s'. Try %s HELP.",
|
||||
c->argv[1]->ptr,cmd);
|
||||
sdsfree(cmd);
|
||||
}
|
||||
|
||||
/* Copy 'src' client output buffers into 'dst' client output buffers.
|
||||
* The function takes care of freeing the old output buffers of the
|
||||
* destination client. */
|
||||
|
@ -1410,6 +1410,7 @@ void addReplyHumanLongDouble(client *c, long double d);
|
||||
void addReplyLongLong(client *c, long long ll);
|
||||
void addReplyMultiBulkLen(client *c, long length);
|
||||
void addReplyHelp(client *c, const char **help);
|
||||
void addReplySubSyntaxError(client *c);
|
||||
void copyClientOutputBuffer(client *dst, client *src);
|
||||
size_t sdsZmallocSize(sds s);
|
||||
size_t getStringObjectSdsUsedMemory(robj *o);
|
||||
|
Loading…
Reference in New Issue
Block a user