StoreBackEnd/pkg/protocol/rules/writers/EraseOkRule.go
2022-03-20 15:32:45 +01:00

39 lines
911 B
Go

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