From 338c337736c27d660ffc7440a2f3c1099ce514a3 Mon Sep 17 00:00:00 2001 From: Mike Cheng Date: Sun, 3 May 2015 14:15:59 -0400 Subject: [PATCH] Use flags for config file and daemon mode --- dyndns/daemon.go | 2 +- main.go | 16 ++++++++-------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/dyndns/daemon.go b/dyndns/daemon.go index 2c2111b..7f3552a 100644 --- a/dyndns/daemon.go +++ b/dyndns/daemon.go @@ -10,7 +10,7 @@ import ( var wg sync.WaitGroup func updateDomain(a api.API, currentIP, domain string) error { - records, err := api.GetRecords(domain) + records, err := a.GetRecords(domain) if err != nil { return err } diff --git a/main.go b/main.go index 672e221..f443ca9 100644 --- a/main.go +++ b/main.go @@ -1,17 +1,19 @@ package main import ( + "flag" "fmt" "github.com/mfycheng/name-dyndns/api" + "github.com/mfycheng/name-dyndns/dyndns" "os" ) -const ( - defaultConfigPath = "./config.json" -) - func main() { - configs, err := api.LoadConfigs(defaultConfigPath) + configPath := flag.String("config", "./config.json", "Specify the configuration file") + daemon := flag.Bool("daemon", false, "operate in daemon mode") + flag.Parse() + + configs, err := api.LoadConfigs(*configPath) if err != nil { fmt.Println("Error loading config:", err) os.Exit(1) @@ -19,7 +21,5 @@ func main() { } fmt.Printf("Successfully loaded %d configs\n", len(configs)) - for _, config := range configs { - fmt.Println("Processing config", config) - } + dyndns.Run(configs, *daemon) }