Skip to content
Browse files

Make main() run for debugging purposes

  • Loading branch information...
1 parent 62ba917 commit 33714c17ead7cf23b6d5a2ec5463e4681c9d107b @mrnugget committed Mar 27, 2013
Showing with 20 additions and 8 deletions.
  1. +1 −2 config.go
  2. +19 −6 watchgopher.go
View
3 config.go
@@ -5,8 +5,6 @@ import (
"io/ioutil"
)
-var f interface{}
-
type Rule struct {
Path string
Run string
@@ -20,6 +18,7 @@ func ParseConfig(path string) (rules []*Rule, err error) {
return nil, err
}
+ var f interface{}
err = json.Unmarshal(c, &f)
if err != nil {
return nil, err
View
25 watchgopher.go
@@ -15,16 +15,29 @@ func main() {
os.Exit(1)
}
- // @TODO: Parse configuration file to get which directories to watch,
- // which pattern to match for which directory, which scripts to run on
- // event
- _, err = ParseConfig(configPath)
+ rules, err := ParseConfig(configPath)
if err != nil {
fmt.Println("Error: Could not parse config file")
+ os.Exit(1)
+ }
+
+ dirs := make([]string, 0)
+ for _, rule := range rules {
+ dirs = append(dirs, rule.Path)
+ }
+
+ watcher, err := WatchDirs(dirs)
+ if err != nil {
+ fmt.Println("Error: Could not start watching directories")
+ fmt.Println(err)
+ os.Exit(1)
}
- // @TODO: Watch directories for events (see `dir_watcher.go`) and pass
- // events to a manager, which checks for appliance of configuration
+ // @TODO: Manage the events, check if a rule applies (file is in path),
+ // then run script with arguments
+ for ev := range watcher.Events {
+ fmt.Println("EVENT - File:", ev.Name)
+ }
// @TODO: If filename matches a pattern (e.g. `*.jpg`), pass it to a worker,
// that shells out and runs configured command with two arguments:

0 comments on commit 33714c1

Please sign in to comment.
Something went wrong with that request. Please try again.