diff --git a/libs/common/RespMemoryWriter.cs b/libs/common/RespMemoryWriter.cs index 8d6ee383374..8a6de25e0f6 100644 --- a/libs/common/RespMemoryWriter.cs +++ b/libs/common/RespMemoryWriter.cs @@ -57,7 +57,7 @@ public void WriteAsciiDirect(ReadOnlySpan span) } /// - /// Writes an array str to memory. + /// Writes an array item to memory. /// [MethodImpl(MethodImplOptions.AggressiveInlining)] public void WriteArrayItem(long item) @@ -192,7 +192,6 @@ public void WriteEmptyMap() /// Write simple error to memory. /// /// An ASCII encoded error string. The string mustn't contain a CR (\r) or LF (\n) bytes. - [MethodImpl(MethodImplOptions.AggressiveInlining)] public void WriteError(scoped ReadOnlySpan errorString) { while (!RespWriteUtils.TryWriteError(errorString, ref curr, end)) @@ -227,6 +226,18 @@ public void TryWriteFalse() } } + /// + /// Write Help output + /// + public void WriteHelp(params string[] Help) + { + WriteArrayLength(Help.Length); + foreach (var help in Help) + { + WriteSimpleString(help); + } + } + /// /// Write integer to memory. /// diff --git a/libs/resources/RespCommandsDocs.json b/libs/resources/RespCommandsDocs.json index e4d86c25bb6..1f9b71e000e 100644 --- a/libs/resources/RespCommandsDocs.json +++ b/libs/resources/RespCommandsDocs.json @@ -68,6 +68,13 @@ } ] }, + { + "Command": "ACL_HELP", + "Name": "ACL|HELP", + "Summary": "Show helpful text about the different subcommands", + "Group": "Server", + "Complexity": "O(1)" + }, { "Command": "ACL_LIST", "Name": "ACL|LIST", @@ -944,6 +951,13 @@ "Group": "Connection", "Complexity": "O(1)" }, + { + "Command": "CLIENT_HELP", + "Name": "CLIENT|HELP", + "Summary": "Show helpful text about the different subcommands", + "Group": "Server", + "Complexity": "O(1)" + }, { "Command": "CLIENT_ID", "Name": "CLIENT|ID", @@ -1722,6 +1736,13 @@ } ] }, + { + "Command": "COMMAND_HELP", + "Name": "COMMAND|HELP", + "Summary": "Show helpful text about the different subcommands", + "Group": "Server", + "Complexity": "O(1)" + }, { "Command": "COMMAND_INFO", "Name": "COMMAND|INFO", @@ -1779,6 +1800,13 @@ } ] }, + { + "Command": "CONFIG_HELP", + "Name": "CONFIG|HELP", + "Summary": "Show helpful text about the different subcommands", + "Group": "Server", + "Complexity": "O(1)" + }, { "Command": "CONFIG_REWRITE", "Name": "CONFIG|REWRITE", @@ -5335,6 +5363,13 @@ "Group": "Server", "Complexity": "Depends on subcommand.", "SubCommands": [ + { + "Command": "MEMORY_HELP", + "Name": "MEMORY|HELP", + "Summary": "Show helpful text about the different subcommands", + "Group": "Server", + "Complexity": "O(1)" + }, { "Command": "MEMORY_USAGE", "Name": "MEMORY|USAGE", @@ -5499,6 +5534,13 @@ "Group": "Server", "Complexity": "Depends on subcommand.", "SubCommands": [ + { + "Command": "MODULE_HELP", + "Name": "MODULE|HELP", + "Summary": "Show helpful text about the different subcommands", + "Group": "Server", + "Complexity": "O(1)" + }, { "Command": "MODULE_LOADCS", "Name": "MODULE|LOADCS", @@ -5931,6 +5973,13 @@ } ] }, + { + "Command": "PUBSUB_HELP", + "Name": "PUBSUB|HELP", + "Summary": "Show helpful text about the different subcommands", + "Group": "Server", + "Complexity": "O(1)" + }, { "Command": "PUBSUB_NUMPAT", "Name": "PUBSUB|NUMPAT", @@ -6590,6 +6639,13 @@ } ] }, + { + "Command": "SCRIPT_HELP", + "Name": "SCRIPT|HELP", + "Summary": "Show helpful text about the different subcommands", + "Group": "Server", + "Complexity": "O(1)" + }, { "Command": "SCRIPT_LOAD", "Name": "SCRIPT|LOAD", diff --git a/libs/resources/RespCommandsInfo.json b/libs/resources/RespCommandsInfo.json index f381ba1548f..5e2a784ee7b 100644 --- a/libs/resources/RespCommandsInfo.json +++ b/libs/resources/RespCommandsInfo.json @@ -86,6 +86,13 @@ "Arity": -2, "Flags": "Loading, NoScript, Stale", "AclCategories": "Slow" + }, + { + "Command": "ACL_HELP", + "Name": "ACL|HELP", + "Arity": 2, + "Flags": "Loading, Stale", + "AclCategories": "Slow" } ] }, @@ -524,6 +531,13 @@ "Flags": "Loading, NoScript, Stale", "AclCategories": "Connection, Slow" }, + { + "Command": "CLIENT_HELP", + "Name": "CLIENT|HELP", + "Arity": 2, + "Flags": "Loading, Stale", + "AclCategories": "Slow" + }, { "Command": "CLIENT_ID", "Name": "CLIENT|ID", @@ -1018,6 +1032,13 @@ "Flags": "Loading, Stale", "AclCategories": "Connection, Slow" }, + { + "Command": "COMMAND_HELP", + "Name": "COMMAND|HELP", + "Arity": 2, + "Flags": "Loading, Stale", + "AclCategories": "Slow" + }, { "Command": "COMMAND_INFO", "Name": "COMMAND|INFO", @@ -1053,6 +1074,13 @@ "Flags": "Admin, Loading, NoScript, Stale", "AclCategories": "Admin, Dangerous, Slow" }, + { + "Command": "CONFIG_HELP", + "Name": "CONFIG|HELP", + "Arity": 2, + "Flags": "Admin, Loading, NoScript, Stale", + "AclCategories": "Slow, Garnet" + }, { "Command": "CONFIG_REWRITE", "Name": "CONFIG|REWRITE", @@ -2781,8 +2809,8 @@ "Command": "LATENCY_HELP", "Name": "LATENCY|HELP", "Arity": 2, - "Flags": "Admin, Loading, NoScript, Stale", - "AclCategories": "Slow, Garnet" + "Flags": "Loading, Stale", + "AclCategories": "Slow" }, { "Command": "LATENCY_HISTOGRAM", @@ -3175,6 +3203,13 @@ "Arity": -2, "AclCategories": "Slow", "SubCommands": [ + { + "Command": "MEMORY_HELP", + "Name": "MEMORY|HELP", + "Arity": 2, + "Flags": "Loading, Stale", + "AclCategories": "Slow" + }, { "Command": "MEMORY_USAGE", "Name": "MEMORY|USAGE", @@ -3285,6 +3320,13 @@ "Arity": -3, "Flags": "Admin, NoAsyncLoading, NoScript", "AclCategories": "Admin, Dangerous, Slow" + }, + { + "Command": "MODULE_HELP", + "Name": "MODULE|HELP", + "Arity": 2, + "Flags": "Loading, Stale", + "AclCategories": "Slow" } ] }, @@ -3636,6 +3678,13 @@ "Flags": "Loading, PubSub, Stale", "AclCategories": "PubSub, Slow" }, + { + "Command": "PUBSUB_HELP", + "Name": "PUBSUB|HELP", + "Arity": 2, + "Flags": "Loading, Stale", + "AclCategories": "Slow" + }, { "Command": "PUBSUB_NUMPAT", "Name": "PUBSUB|NUMPAT", @@ -4035,6 +4084,13 @@ "response_policy:all_succeeded" ] }, + { + "Command": "SCRIPT_HELP", + "Name": "SCRIPT|HELP", + "Arity": 2, + "Flags": "Loading, Stale", + "AclCategories": "Slow" + }, { "Command": "SCRIPT_LOAD", "Name": "SCRIPT|LOAD", diff --git a/libs/server/Lua/LuaCommands.cs b/libs/server/Lua/LuaCommands.cs index 07d6dcd41ab..05e037e7208 100644 --- a/libs/server/Lua/LuaCommands.cs +++ b/libs/server/Lua/LuaCommands.cs @@ -271,6 +271,34 @@ private bool NetworkScriptFlush() return true; } + + /// + /// SCRIPT HELP + /// + /// + private bool NetworkScriptHelp() + { + if (parseState.Count != 0) + { + return AbortWithWrongNumberOfArguments("script|help"); + } + + WriteHelp( + "SCRIPT [ [value] [opt] ...]. Subcommands are:", + "EXISTS [ ...]", + "\tReturn information about the existence of the scripts in the script cache.", + "FLUSH [ASYNC|SYNC]", + "\tFlush the Lua scripts cache. Very dangerous on replicas. Valid modes are:", + "\t* ASYNC: Asynchronously flush the scripts cache.", + "\t* SYNC: Synchronously flush the scripts cache.", + "LOAD