diff options
author | Dimitri Sokolyuk <demon@dim13.org> | 2015-12-18 16:14:17 +0100 |
---|---|---|
committer | Dimitri Sokolyuk <demon@dim13.org> | 2015-12-18 16:14:17 +0100 |
commit | 9e6973bffbf876ea6cbd403f211dd81798ec89dd (patch) | |
tree | c713126e52e3a12e9bbf6b9e898adf277332d161 | |
parent | e3c7e4284f22f1975f7809bd23501e3529da8d12 (diff) |
KISS
-rw-r--r-- | hook.go | 20 |
1 files changed, 20 insertions, 0 deletions
@@ -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) + } + } +} |