split actions/trigggers into seperate files
This commit is contained in:
28
actions/printer.go
Normal file
28
actions/printer.go
Normal 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
|
||||
}
|
||||
Reference in New Issue
Block a user