package main import ( "fmt" "sort" "go.eth.moe/dispatch/config" "go.eth.moe/flag" "go.eth.moe/logger" ) var ( configPath = flag.Custom("config-path", "", "path to config.json", flag.RequiredString) ) func main() { flag.Parse() configPath := (*configPath).(string) log := logger.Background() cfg, err := config.ParseFile(configPath) if err != nil { log.AddField("config-path", configPath) log.WithError(err).Fatal("could not parse config") } var names []string for name := range cfg.RulesByName { names = append(names, name) } sort.Strings(names) for _, name := range names { rule := cfg.RulesByName[name] fmt.Printf("%v:\n", name) fmt.Printf("- triggers:\n") for _, trigger := range rule.Triggers { fmt.Printf(" - url: %v\n", trigger.URL) } fmt.Printf("- actions:\n") for _, action := range rule.Actions { switch action.Kind { case config.HTTPAction: fmt.Printf(" - url: %v\n", action.URL) case config.MQTTAction: fmt.Printf(" - mqtt: %v\n", action.MQTT) fmt.Printf(" - value: %v\n", action.Value) } } } }