From 23f6dd41879988ee804cc6c81419e5b18ec6aabe Mon Sep 17 00:00:00 2001 From: y_uuki Date: Fri, 5 Jun 2020 03:27:34 +0900 Subject: [PATCH] Support additional flags for ACL in CommandsInfo --- command.go | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/command.go b/command.go index fa1b03e..c1130e2 100644 --- a/command.go +++ b/command.go @@ -1885,6 +1885,7 @@ type CommandInfo struct { Name string Arity int8 Flags []string + ACLFlags []string FirstKeyPos int8 LastKeyPos int8 StepCount int8 @@ -1934,8 +1935,8 @@ func (cmd *CommandsInfoCmd) readReply(rd *proto.Reader) error { } func commandInfoParser(rd *proto.Reader, n int64) (interface{}, error) { - if n != 6 { - return nil, fmt.Errorf("redis: got %d elements in COMMAND reply, wanted 6", n) + if n != 7 { + return nil, fmt.Errorf("redis: got %d elements in COMMAND reply, wanted 7", n) } var cmd CommandInfo @@ -1988,6 +1989,24 @@ func commandInfoParser(rd *proto.Reader, n int64) (interface{}, error) { } cmd.StepCount = int8(stepCount) + _, err = rd.ReadReply(func(rd *proto.Reader, n int64) (interface{}, error) { + cmd.ACLFlags = make([]string, n) + for i := 0; i < len(cmd.Flags); i++ { + switch s, err := rd.ReadString(); { + case err == Nil: + cmd.ACLFlags[i] = "" + case err != nil: + return nil, err + default: + cmd.ACLFlags[i] = s + } + } + return nil, nil + }) + if err != nil { + return nil, err + } + for _, flag := range cmd.Flags { if flag == "readonly" { cmd.ReadOnly = true