From 3a8802214a05fed4a0828b1f2965ac140e11ee32 Mon Sep 17 00:00:00 2001 From: dvora-h <67596500+dvora-h@users.noreply.github.com> Date: Sun, 8 May 2022 15:05:43 +0300 Subject: Add support for COMMAND LIST (#2149) * Add support for COMMAND LIST * style change --- redis/commands/core.py | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) (limited to 'redis/commands/core.py') diff --git a/redis/commands/core.py b/redis/commands/core.py index 6526ef1..073161f 100644 --- a/redis/commands/core.py +++ b/redis/commands/core.py @@ -769,6 +769,34 @@ class ManagementCommands(CommandsProtocol): def command_count(self, **kwargs) -> ResponseT: return self.execute_command("COMMAND COUNT", **kwargs) + def command_list( + self, + module: Optional[str] = None, + category: Optional[str] = None, + pattern: Optional[str] = None, + ) -> ResponseT: + """ + Return an array of the server's command names. + You can use one of the following filters: + ``module``: get the commands that belong to the module + ``category``: get the commands in the ACL category + ``pattern``: get the commands that match the given pattern + + For more information see https://redis.io/commands/command-list/ + """ + pieces = [] + if module is not None: + pieces.extend(["MODULE", module]) + if category is not None: + pieces.extend(["ACLCAT", category]) + if pattern is not None: + pieces.extend(["PATTERN", pattern]) + + if pieces: + pieces.insert(0, "FILTERBY") + + return self.execute_command("COMMAND LIST", *pieces) + def command_getkeysandflags(self, *args: List[str]) -> List[Union[str, List[str]]]: """ Returns array of keys from a full Redis command and their usage flags. -- cgit v1.2.1