package writers import "StoreBackEnd/pkg/protocol" // HelloRulePrefix Rule command prefix const HelloRulePrefix = "HELLO" // HelloRule Storage structure for the HelloRule type HelloRule struct { // cmd Rule name cmd string // matcher Allow to make a regex match matcher *protocol.RegexMatcher } // CreateHelloRule Creating an instance of HelloRule func CreateHelloRule(pattern string) protocol.IProtocolWriter { return &HelloRule{ cmd: HelloRulePrefix, matcher: protocol.CreateRegexMatcher(pattern), } } // GetCmd retrieve the command name. func (rule HelloRule) GetCmd() string { return rule.cmd } // Execute the Rule with a string command. func (rule HelloRule) Execute(argsData ...string) *protocol.ProtocolWriterResult { cmd, _ := rule.matcher.Build(HelloRulePrefix, argsData...) return &protocol.ProtocolWriterResult{ Cmd: cmd, } }