Tranformation d'une commande (chaine de char) en tableau. Il est donc désormais possible de lire une commande et l'interprêter

This commit is contained in:
2022-02-22 10:52:07 +01:00
parent 09d4834cdf
commit 233f7ac582
5 changed files with 16 additions and 9 deletions

View File

@@ -15,7 +15,7 @@ type EraseFileRule struct {
}
// CreateEraseFileRule Création d'une instance de EraseFileRule
func CreateEraseFileRule(pattern string) *EraseFileRule {
func CreateEraseFileRule(pattern string) protocol.IProtocolReader {
return &EraseFileRule{
Cmd: EraseFileRuleName,
matcher: protocol.CreateRegexMatcher(pattern),
@@ -26,12 +26,14 @@ func (rule EraseFileRule) GetCmd() string {
return rule.Cmd
}
func (rule EraseFileRule) Execute(data string) string {
func (rule EraseFileRule) Execute(data string) (string, bool) {
if rule.Match(data) {
return "Parsing : EraseFileRule command fichier supprimé"
values := rule.matcher.Parse(data)
println(values[1], " est le hash du fichier à supprimer")
return "Parsing : Fichier avec le hash " + values[1] + " supprimé", true
} else {
return "Parsing : EraseFileRule command fichier non-supprimé"
return "Parsing : EraseFileRule command incorrecte", false
}
}