aboutsummaryrefslogtreecommitdiff
path: root/hook.go
diff options
context:
space:
mode:
authorDimitri Sokolyuk <demon@dim13.org>2015-12-18 16:14:17 +0100
committerDimitri Sokolyuk <demon@dim13.org>2015-12-18 16:14:17 +0100
commit9e6973bffbf876ea6cbd403f211dd81798ec89dd (patch)
treec713126e52e3a12e9bbf6b9e898adf277332d161 /hook.go
parente3c7e4284f22f1975f7809bd23501e3529da8d12 (diff)
KISS
Diffstat (limited to 'hook.go')
-rw-r--r--hook.go20
1 files changed, 20 insertions, 0 deletions
diff --git a/hook.go b/hook.go
index 67dbf6a..a5c84da 100644
--- a/hook.go
+++ b/hook.go
@@ -6,11 +6,14 @@ import (
"strings"
)
+type Hooker map[string]bool
+
func execHook(s string) error {
cmd := strings.Fields(s)
return exec.Command(cmd[0], cmd[1:]...).Run()
}
+/*
func NewHooker() chan string {
h := make(chan string, 2)
go func() {
@@ -22,3 +25,20 @@ func NewHooker() chan string {
}()
return h
}
+*/
+
+func NewHooker() Hooker {
+ return make(Hooker)
+}
+
+func (h Hooker) Notice(cmd string) {
+ h[cmd] = true
+}
+
+func (h Hooker) Execute() {
+ for cmd := range h {
+ if err := execHook(cmd); err != nil {
+ log.Println(cmd, err)
+ }
+ }
+}