1
0
mirror of https://github.com/redis/go-redis.git synced 2025-07-28 06:42:00 +03:00

Add: Support for COMMAND LIST command (#2491)

* feat: add support and tests for Command list command

Co-authored-by: Anuragkillswitch <70265851+Anuragkillswitch@users.noreply.github.com>
This commit is contained in:
Anurag Bandyopadhyay
2023-03-19 15:50:42 +05:30
committed by GitHub
parent 30a6f7107e
commit 049d4f9691
3 changed files with 76 additions and 0 deletions

View File

@ -124,6 +124,7 @@ type Cmdable interface {
TxPipeline() Pipeliner
Command(ctx context.Context) *CommandsInfoCmd
CommandList(ctx context.Context, filter *FilterBy) *StringSliceCmd
ClientGetName(ctx context.Context) *StringCmd
Echo(ctx context.Context, message interface{}) *StringCmd
Ping(ctx context.Context) *StatusCmd
@ -537,6 +538,23 @@ func (c cmdable) Command(ctx context.Context) *CommandsInfoCmd {
return cmd
}
func (c cmdable) CommandList(ctx context.Context, filter *FilterBy) *StringSliceCmd {
args := make([]interface{}, 0, 5)
args = append(args, "command", "list")
if filter != nil {
if filter.Module != "" {
args = append(args, "filterby", "module", filter.Module)
} else if filter.ACLCat != "" {
args = append(args, "filterby", "aclcat", filter.ACLCat)
} else if filter.Pattern != "" {
args = append(args, "filterby", "pattern", filter.Pattern)
}
}
cmd := NewStringSliceCmd(ctx, args...)
_ = c(ctx, cmd)
return cmd
}
// ClientGetName returns the name of the connection.
func (c cmdable) ClientGetName(ctx context.Context) *StringCmd {
cmd := NewStringCmd(ctx, "client", "getname")