StoreBackEnd/pkg/protocol/rules/writers/EraseOkRule.go

46 lines
1005 B
Go
Raw Permalink Normal View History

2022-03-13 15:49:06 +01:00
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,
}
}
/*
func onWrite(writer *bufio.Writer) {
println("Ecriture du fichier sur le réseau")
}
*/