From 7dc034b8192a75863b661cc4ca4bc49b8caa2846 Mon Sep 17 00:00:00 2001 From: Cheyu Wu Date: Wed, 12 Feb 2025 21:38:19 +0800 Subject: [PATCH] feat: Add ACLCatArgs to rueidiscompat --- rueidiscompat/adapter.go | 15 +++++++++++++++ rueidiscompat/pipeline.go | 6 ++++++ 2 files changed, 21 insertions(+) diff --git a/rueidiscompat/adapter.go b/rueidiscompat/adapter.go index 59fca43e..4b14a818 100644 --- a/rueidiscompat/adapter.go +++ b/rueidiscompat/adapter.go @@ -420,6 +420,7 @@ type CoreCmdable interface { ACLDelUser(ctx context.Context, username string) *IntCmd ACLLogReset(ctx context.Context) *StatusCmd ACLCat(ctx context.Context) *StringSliceCmd + ACLCatArgs(ctx context.Context, options *ACLCatArgs) *StringSliceCmd ModuleLoadex(ctx context.Context, conf *ModuleLoadexConfig) *StringCmd GearsCmdable @@ -3211,6 +3212,20 @@ func (c *Compat) ACLDryRun(ctx context.Context, username string, command ...any) return newStringCmd(resp) } +type ACLCatArgs struct { + Category string +} + +func (c *Compat) ACLCatArgs(ctx context.Context, options *ACLCatArgs) *StringSliceCmd { + // if there is a category passed, build new cmd, if there isn't - use the ACLCat method + if options != nil && options.Category != "" { + cmd := c.client.B().AclCat().Categoryname(options.Category).Build() + resp := c.client.Do(ctx, cmd) + return newStringSliceCmd(resp) + } + return c.ACLCat(ctx) +} + func (c *Compat) ACLLog(ctx context.Context, count int64) *ACLLogCmd { cmd := c.client.B().AclLog().Count(count).Build() resp := c.client.Do(ctx, cmd) diff --git a/rueidiscompat/pipeline.go b/rueidiscompat/pipeline.go index 6ba6f408..746d24ce 100644 --- a/rueidiscompat/pipeline.go +++ b/rueidiscompat/pipeline.go @@ -2125,6 +2125,12 @@ func (c *Pipeline) ACLCat(ctx context.Context) *StringSliceCmd { return ret } +func (c *Pipeline) ACLCatArgs(ctx context.Context, options *ACLCatArgs) *StringSliceCmd { + ret := c.comp.ACLCatArgs(ctx, options) + c.rets = append(c.rets, ret) + return ret +} + func (c *Pipeline) TFunctionLoad(ctx context.Context, lib string) *StatusCmd { ret := c.comp.TFunctionLoad(ctx, lib) c.rets = append(c.rets, ret)