mirror of
https://github.com/fluencelabs/redis
synced 2025-03-19 09:00:51 +00:00
Change indentation and other minor details of PR #4489.
The main change introduced by this commit is pretending that help arrays are more text than code, thus indenting them at level 0. This improves readability, and is an old practice when defining arrays of C strings describing text. Additionally a few useless return statements are removed, and the HELP subcommand capitalized when printed to the user.
This commit is contained in:
parent
482d678e95
commit
522760fac7
@ -4067,29 +4067,29 @@ void clusterCommand(client *c) {
|
||||
|
||||
if (c->argc == 2 && !strcasecmp(c->argv[1]->ptr,"help")) {
|
||||
const char *help[] = {
|
||||
"addslots <slot> [slot ...] -- Assign slots to current node.",
|
||||
"bumpepoch -- Advance the cluster config epoch.",
|
||||
"count-failure-reports <node-id> -- Return number of failure reports for <node-id>.",
|
||||
"countkeysinslot <slot> - Return the number of keys in <slot>.",
|
||||
"delslots <slot> [slot ...] -- Delete slots information from current node.",
|
||||
"failover [force|takeover] -- Promote current slave node to being a master.",
|
||||
"forget <node-id> -- Remove a node from the cluster.",
|
||||
"getkeysinslot <slot> <count> -- Return key names stored by current node in a slot.",
|
||||
"flushslots -- Delete current node own slots information.",
|
||||
"info - Return onformation about the cluster.",
|
||||
"keyslot <key> -- Return the hash slot for <key>.",
|
||||
"meet <ip> <port> [bus-port] -- Connect nodes into a working cluster.",
|
||||
"myid -- Return the node id.",
|
||||
"nodes -- Return cluster configuration seen by node. Output format:",
|
||||
" <id> <ip:port> <flags> <master> <pings> <pongs> <epoch> <link> <slot> ... <slot>",
|
||||
"replicate <node-id> -- Configure current node as slave to <node-id>.",
|
||||
"reset [hard|soft] -- Reset current node (default: soft).",
|
||||
"set-config-epoch <epoch> - Set config epoch of current node.",
|
||||
"setslot <slot> (importing|migrating|stable|node <node-id>) -- Set slot state.",
|
||||
"slaves <node-id> -- Return <node-id> slaves.",
|
||||
"slots -- Return information about slots range mappings. Each range is made of:",
|
||||
" start, end, master and replicas IP addresses, ports and ids",
|
||||
NULL
|
||||
"addslots <slot> [slot ...] -- Assign slots to current node.",
|
||||
"bumpepoch -- Advance the cluster config epoch.",
|
||||
"count-failure-reports <node-id> -- Return number of failure reports for <node-id>.",
|
||||
"countkeysinslot <slot> - Return the number of keys in <slot>.",
|
||||
"delslots <slot> [slot ...] -- Delete slots information from current node.",
|
||||
"failover [force|takeover] -- Promote current slave node to being a master.",
|
||||
"forget <node-id> -- Remove a node from the cluster.",
|
||||
"getkeysinslot <slot> <count> -- Return key names stored by current node in a slot.",
|
||||
"flushslots -- Delete current node own slots information.",
|
||||
"info - Return onformation about the cluster.",
|
||||
"keyslot <key> -- Return the hash slot for <key>.",
|
||||
"meet <ip> <port> [bus-port] -- Connect nodes into a working cluster.",
|
||||
"myid -- Return the node id.",
|
||||
"nodes -- Return cluster configuration seen by node. Output format:",
|
||||
" <id> <ip:port> <flags> <master> <pings> <pongs> <epoch> <link> <slot> ... <slot>",
|
||||
"replicate <node-id> -- Configure current node as slave to <node-id>.",
|
||||
"reset [hard|soft] -- Reset current node (default: soft).",
|
||||
"set-config-epoch <epoch> - Set config epoch of current node.",
|
||||
"setslot <slot> (importing|migrating|stable|node <node-id>) -- Set slot state.",
|
||||
"slaves <node-id> -- Return <node-id> slaves.",
|
||||
"slots -- Return information about slots range mappings. Each range is made of:",
|
||||
" start, end, master and replicas IP addresses, ports and ids",
|
||||
NULL
|
||||
};
|
||||
addReplyHelp(c, help);
|
||||
} else if (!strcasecmp(c->argv[1]->ptr,"meet") && (c->argc == 4 || c->argc == 5)) {
|
||||
@ -4285,7 +4285,7 @@ void clusterCommand(client *c) {
|
||||
clusterAddSlot(n,slot);
|
||||
} else {
|
||||
addReplyError(c,
|
||||
"Invalid CLUSTER SETSLOT action or number of arguments. Try CLUSTER help");
|
||||
"Invalid CLUSTER SETSLOT action or number of arguments. Try CLUSTER HELP");
|
||||
return;
|
||||
}
|
||||
clusterDoBeforeSleep(CLUSTER_TODO_SAVE_CONFIG|CLUSTER_TODO_UPDATE_STATE);
|
||||
@ -4635,7 +4635,7 @@ void clusterCommand(client *c) {
|
||||
clusterReset(hard);
|
||||
addReply(c,shared.ok);
|
||||
} else {
|
||||
addReplyErrorFormat(c, "Unknown subcommand or wrong number of arguments for '%s'. Try CLUSTER help",
|
||||
addReplyErrorFormat(c, "Unknown subcommand or wrong number of arguments for '%s'. Try CLUSTER HELP",
|
||||
(char*)c->argv[1]->ptr);
|
||||
return;
|
||||
}
|
||||
|
12
src/config.c
12
src/config.c
@ -2071,11 +2071,11 @@ void configCommand(client *c) {
|
||||
|
||||
if (c->argc == 2 && !strcasecmp(c->argv[1]->ptr,"help")) {
|
||||
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
|
||||
"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) {
|
||||
@ -2099,7 +2099,7 @@ void configCommand(client *c) {
|
||||
addReply(c,shared.ok);
|
||||
}
|
||||
} else {
|
||||
addReplyErrorFormat(c, "Unknown subcommand or wrong number of arguments for '%s'. Try SLOWLOG help",
|
||||
addReplyErrorFormat(c, "Unknown subcommand or wrong number of arguments for '%s'. Try CONFIG HELP",
|
||||
(char*)c->argv[1]->ptr);
|
||||
return;
|
||||
}
|
||||
|
42
src/debug.c
42
src/debug.c
@ -285,26 +285,26 @@ void computeDatasetDigest(unsigned char *final) {
|
||||
void debugCommand(client *c) {
|
||||
if (c->argc == 2 && !strcasecmp(c->argv[1]->ptr,"help")) {
|
||||
const char *help[] = {
|
||||
"assert -- Crash by assertion failed.",
|
||||
"change-repl-id -- Change the replication IDs of the instance. Dangerous, should be used only for testing the replication subsystem.",
|
||||
"crash-and-recovery <milliseconds> -- Hard crash and restart after <milliseconds> delay.",
|
||||
"digest -- Outputs an hex signature representing the current DB content.",
|
||||
"htstats <dbid> -- Return hash table statistics of the specified Redis database.",
|
||||
"loadaof -- Flush the AOF buffers on disk and reload the AOF in memory.",
|
||||
"lua-always-replicate-commands (0|1) -- Setting it to 1 makes Lua replication defaulting to replicating single commands, without the script having to enable effects replication.",
|
||||
"object <key> -- Show low level info about key and associated value.",
|
||||
"panic -- Crash the server simulating a panic.",
|
||||
"populate <count> [prefix] [size] -- Create <count> string keys named key:<num>. If a prefix is specified is used instead of the 'key' prefix.",
|
||||
"reload -- Save the RDB on disk and reload it back in memory.",
|
||||
"restart -- Graceful restart: save config, db, restart.",
|
||||
"sdslen <key> -- Show low level SDS string info representing key and value.",
|
||||
"segfault -- Crash the server with sigsegv.",
|
||||
"set-active-expire (0|1) -- Setting it to 0 disables expiring keys in background when they are not accessed (otherwise the Redis behavior). Setting it to 1 reenables back the default.",
|
||||
"sleep <seconds> -- Stop the server for <seconds>. Decimals allowed.",
|
||||
"structsize -- Return the size of different Redis core C structures.",
|
||||
"ziplist <key> -- Show low level info about the ziplist encoding.",
|
||||
"error <string> -- Return a Redis protocol error with <string> as message. Useful for clients unit tests to simulate Redis errors.",
|
||||
NULL
|
||||
"assert -- Crash by assertion failed.",
|
||||
"change-repl-id -- Change the replication IDs of the instance. Dangerous, should be used only for testing the replication subsystem.",
|
||||
"crash-and-recovery <milliseconds> -- Hard crash and restart after <milliseconds> delay.",
|
||||
"digest -- Outputs an hex signature representing the current DB content.",
|
||||
"htstats <dbid> -- Return hash table statistics of the specified Redis database.",
|
||||
"loadaof -- Flush the AOF buffers on disk and reload the AOF in memory.",
|
||||
"lua-always-replicate-commands (0|1) -- Setting it to 1 makes Lua replication defaulting to replicating single commands, without the script having to enable effects replication.",
|
||||
"object <key> -- Show low level info about key and associated value.",
|
||||
"panic -- Crash the server simulating a panic.",
|
||||
"populate <count> [prefix] [size] -- Create <count> string keys named key:<num>. If a prefix is specified is used instead of the 'key' prefix.",
|
||||
"reload -- Save the RDB on disk and reload it back in memory.",
|
||||
"restart -- Graceful restart: save config, db, restart.",
|
||||
"sdslen <key> -- Show low level SDS string info representing key and value.",
|
||||
"segfault -- Crash the server with sigsegv.",
|
||||
"set-active-expire (0|1) -- Setting it to 0 disables expiring keys in background when they are not accessed (otherwise the Redis behavior). Setting it to 1 reenables back the default.",
|
||||
"sleep <seconds> -- Stop the server for <seconds>. Decimals allowed.",
|
||||
"structsize -- Return the size of different Redis core C structures.",
|
||||
"ziplist <key> -- Show low level info about the ziplist encoding.",
|
||||
"error <string> -- Return a Redis protocol error with <string> as message. Useful for clients unit tests to simulate Redis errors.",
|
||||
NULL
|
||||
};
|
||||
addReplyHelp(c, help);
|
||||
} else if (!strcasecmp(c->argv[1]->ptr,"segfault")) {
|
||||
@ -553,7 +553,7 @@ void debugCommand(client *c) {
|
||||
clearReplicationId2();
|
||||
addReply(c,shared.ok);
|
||||
} else {
|
||||
addReplyErrorFormat(c, "Unknown subcommand or wrong number of arguments for '%s'. Try DEBUG help",
|
||||
addReplyErrorFormat(c, "Unknown subcommand or wrong number of arguments for '%s'. Try DEBUG HELP",
|
||||
(char*)c->argv[1]->ptr);
|
||||
return;
|
||||
}
|
||||
|
@ -578,7 +578,7 @@ void addReplyBulkSds(client *c, sds s) {
|
||||
addReply(c,shared.crlf);
|
||||
}
|
||||
|
||||
/* Add a C nul term string as bulk reply */
|
||||
/* Add a C null term string as bulk reply */
|
||||
void addReplyBulkCString(client *c, const char *s) {
|
||||
if (s == NULL) {
|
||||
addReply(c,shared.nullbulk);
|
||||
@ -596,7 +596,7 @@ void addReplyBulkLongLong(client *c, long long ll) {
|
||||
addReplyBulkCBuffer(c,buf,len);
|
||||
}
|
||||
|
||||
/* Add an array of strings as a bulk reply with a heading.
|
||||
/* Add an array of C strings as status replies with a heading.
|
||||
* This function is typically invoked by from commands that support
|
||||
* subcommands in response to the 'help' subcommand. The help array
|
||||
* is terminated by NULL sentinel. */
|
||||
@ -1591,17 +1591,17 @@ void clientCommand(client *c) {
|
||||
|
||||
if (c->argc == 2 && !strcasecmp(c->argv[1]->ptr,"help")) {
|
||||
const char *help[] = {
|
||||
"getname -- Return the name of the current connection.",
|
||||
"kill <ip:port> -- Kill connection made from <ip:port>.",
|
||||
"kill <option> <value> [option value ...] -- Kill connections. Options are:",
|
||||
" addr <ip:port> -- Kill connection made from <ip:port>.",
|
||||
" type (normal|master|slave|pubsub) -- Kill connections by type.",
|
||||
" skipme (yes|no) -- Skip killing current connection (default: yes).",
|
||||
"list -- Return information about client connections.",
|
||||
"pause <timeout> -- Suspend all Redis clients for <timout> milliseconds.",
|
||||
"reply (on|off|skip) -- Control the replies sent to the current connection.",
|
||||
"setname <name> -- Assign the name <name> to the current connection.",
|
||||
NULL
|
||||
"getname -- Return the name of the current connection.",
|
||||
"kill <ip:port> -- Kill connection made from <ip:port>.",
|
||||
"kill <option> <value> [option value ...] -- Kill connections. Options are:",
|
||||
" addr <ip:port> -- Kill connection made from <ip:port>.",
|
||||
" type (normal|master|slave|pubsub) -- Kill connections by type.",
|
||||
" skipme (yes|no) -- Skip killing current connection (default: yes).",
|
||||
"list -- Return information about client connections.",
|
||||
"pause <timeout> -- Suspend all Redis clients for <timout> milliseconds.",
|
||||
"reply (on|off|skip) -- Control the replies sent to the current connection.",
|
||||
"setname <name> -- Assign the name <name> to the current connection.",
|
||||
NULL
|
||||
};
|
||||
addReplyHelp(c, help);
|
||||
} else if (!strcasecmp(c->argv[1]->ptr,"list") && c->argc == 2) {
|
||||
@ -1750,9 +1750,8 @@ void clientCommand(client *c) {
|
||||
pauseClients(duration);
|
||||
addReply(c,shared.ok);
|
||||
} else {
|
||||
addReplyErrorFormat(c, "Unknown subcommand or wrong number of arguments for '%s'. Try CLIENT help",
|
||||
(char*)c->argv[1]->ptr);
|
||||
return; }
|
||||
addReplyErrorFormat(c, "Unknown subcommand or wrong number of arguments for '%s'. Try CLIENT HELP", (char*)c->argv[1]->ptr);
|
||||
}
|
||||
}
|
||||
|
||||
/* This callback is bound to POST and "Host:" command names. Those are not
|
||||
|
14
src/object.c
14
src/object.c
@ -1073,11 +1073,11 @@ void objectCommand(client *c) {
|
||||
|
||||
if (c->argc == 2 && !strcasecmp(c->argv[1]->ptr,"help")) {
|
||||
const char *help[] = {
|
||||
"encoding <key> -- Return the kind of internal representation used in order to store the value associated with a key.",
|
||||
"freq <key> -- Return the access frequency index of the key. The returned integer is proportional to the logarithm of the recent access frequency of the key.",
|
||||
"idletime <key> -- Return the idle time of the key, that is the approximated number of seconds elapsed since the last access to the key.",
|
||||
"refcount <key> -- Return the number of references of the value associated with the specified key.",
|
||||
NULL
|
||||
"encoding <key> -- Return the kind of internal representation used in order to store the value associated with a key.",
|
||||
"freq <key> -- Return the access frequency index of the key. The returned integer is proportional to the logarithm of the recent access frequency of the key.",
|
||||
"idletime <key> -- Return the idle time of the key, that is the approximated number of seconds elapsed since the last access to the key.",
|
||||
"refcount <key> -- Return the number of references of the value associated with the specified key.",
|
||||
NULL
|
||||
};
|
||||
addReplyHelp(c, help);
|
||||
} else if (!strcasecmp(c->argv[1]->ptr,"refcount") && c->argc == 3) {
|
||||
@ -1109,9 +1109,7 @@ void objectCommand(client *c) {
|
||||
* when the key is read or overwritten. */
|
||||
addReplyLongLong(c,LFUDecrAndReturn(o));
|
||||
} else {
|
||||
addReplyErrorFormat(c, "Unknown subcommand or wrong number of arguments for '%s'. Try OBJECT help",
|
||||
(char *)c->argv[1]->ptr);
|
||||
return;
|
||||
addReplyErrorFormat(c, "Unknown subcommand or wrong number of arguments for '%s'. Try OBJECT help", (char *)c->argv[1]->ptr);
|
||||
}
|
||||
}
|
||||
|
||||
|
11
src/pubsub.c
11
src/pubsub.c
@ -327,10 +327,10 @@ void publishCommand(client *c) {
|
||||
void pubsubCommand(client *c) {
|
||||
if (c->argc == 2 && !strcasecmp(c->argv[1]->ptr,"help")) {
|
||||
const char *help[] = {
|
||||
"channels [<pattern>] -- Return the currently active channels matching a pattern (default: all).",
|
||||
"numpat -- Return number of subscriptions to patterns.",
|
||||
"numsub [channel-1 .. channel-N] -- Returns the number of subscribers for the specified channels (excluding patterns, default: none).",
|
||||
NULL
|
||||
"channels [<pattern>] -- Return the currently active channels matching a pattern (default: all).",
|
||||
"numpat -- Return number of subscriptions to patterns.",
|
||||
"numsub [channel-1 .. channel-N] -- Returns the number of subscribers for the specified channels (excluding patterns, default: none).",
|
||||
NULL
|
||||
};
|
||||
addReplyHelp(c, help);
|
||||
} else if (!strcasecmp(c->argv[1]->ptr,"channels") &&
|
||||
@ -372,8 +372,7 @@ void pubsubCommand(client *c) {
|
||||
/* PUBSUB NUMPAT */
|
||||
addReplyLongLong(c,listLength(server.pubsub_patterns));
|
||||
} else {
|
||||
addReplyErrorFormat(c, "Unknown subcommand or wrong number of arguments for '%s'. Try PUBSUB help",
|
||||
addReplyErrorFormat(c, "Unknown subcommand or wrong number of arguments for '%s'. Try PUBSUB HELP",
|
||||
(char*)c->argv[1]->ptr);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -1457,12 +1457,12 @@ void evalShaCommand(client *c) {
|
||||
void scriptCommand(client *c) {
|
||||
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
|
||||
"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. Very dangerous on slaves.",
|
||||
"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")) {
|
||||
@ -1514,9 +1514,7 @@ void scriptCommand(client *c) {
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
addReplyErrorFormat(c, "Unknown subcommand or wrong number of arguments for '%s'. Try SCRIPT help",
|
||||
(char*)c->argv[1]->ptr);
|
||||
return;
|
||||
addReplyErrorFormat(c, "Unknown subcommand or wrong number of arguments for '%s'. Try SCRIPT HELP", (char*)c->argv[1]->ptr);
|
||||
}
|
||||
}
|
||||
|
||||
|
14
src/server.c
14
src/server.c
@ -2769,11 +2769,11 @@ void commandCommand(client *c) {
|
||||
|
||||
if (c->argc == 2 && !strcasecmp(c->argv[1]->ptr,"help")) {
|
||||
const char *help[] = {
|
||||
"(no subcommand) -- Return details about all Redis commands.",
|
||||
"count -- Return the total number of commands in this Redis server.",
|
||||
"getkeys <full-command> -- Return the keys from a full Redis command.",
|
||||
"info [command-name ...] -- Return details about multiple Redis commands.",
|
||||
NULL
|
||||
"(no subcommand) -- Return details about all Redis commands.",
|
||||
"count -- Return the total number of commands in this Redis server.",
|
||||
"getkeys <full-command> -- Return the keys from a full Redis command.",
|
||||
"info [command-name ...] -- Return details about multiple Redis commands.",
|
||||
NULL
|
||||
};
|
||||
addReplyHelp(c, help);
|
||||
} else if (c->argc == 1) {
|
||||
@ -2810,9 +2810,7 @@ void commandCommand(client *c) {
|
||||
for (j = 0; j < numkeys; j++) addReplyBulk(c,c->argv[keys[j]+2]);
|
||||
getKeysFreeResult(keys);
|
||||
} else {
|
||||
addReplyErrorFormat(c, "Unknown subcommand or wrong number of arguments for '%s'. Try COMMAND help",
|
||||
(char*)c->argv[1]->ptr);
|
||||
return;
|
||||
addReplyErrorFormat(c, "Unknown subcommand or wrong number of arguments for '%s'. Try COMMAND HELP", (char*)c->argv[1]->ptr);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -142,11 +142,12 @@ void slowlogReset(void) {
|
||||
void slowlogCommand(client *c) {
|
||||
if (c->argc == 2 && !strcasecmp(c->argv[1]->ptr,"help")) {
|
||||
const char *help[] = {
|
||||
"get [count] -- Return top entries from the slowlog (default: 10). Entries are made of:",
|
||||
" id, timestamp, time in microseconds, arguments array, client IP and port, client name",
|
||||
"len -- Return the length of the slowlog.",
|
||||
"reset -- Reset the slowlog.",
|
||||
NULL
|
||||
"get [count] -- Return top entries from the slowlog (default: 10)."
|
||||
" Entries are made of:",
|
||||
" id, timestamp, time in microseconds, arguments array, client IP and port, client name",
|
||||
"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")) {
|
||||
@ -186,8 +187,6 @@ void slowlogCommand(client *c) {
|
||||
}
|
||||
setDeferredMultiBulkLength(c,totentries,sent);
|
||||
} else {
|
||||
addReplyErrorFormat(c, "Unknown subcommand or wrong number of arguments for '%s'. Try SLOWLOG help",
|
||||
(char*)c->argv[1]->ptr);
|
||||
return;
|
||||
addReplyErrorFormat(c, "Unknown subcommand or wrong number of arguments for '%s'. Try SLOWLOG HELP", (char*)c->argv[1]->ptr);
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user