split actions/trigggers into seperate files

This commit is contained in:
2023-07-18 09:34:47 +02:00
parent a2ea3209f1
commit a457a313b7
7 changed files with 132 additions and 121 deletions

28
actions/printer.go Normal file
View File

@@ -0,0 +1,28 @@
package actions
import (
"fmt"
"unknown.com/gokill/internal"
)
type Printer struct {
Message string
ActionChan chan bool
}
func (p Printer) Execute() {
fmt.Printf("Print action fires. Message: %s", p.Message)
p.ActionChan <- true
}
func NewPrint(config internal.ActionConfig, c chan bool) (Action, error) {
opts := config.Options
message, ok := opts["message"]
if !ok {
return nil, internal.OptionMissingError{"message"}
}
return Printer{fmt.Sprintf("%v", message), c}, nil
}