Use flags for config file and daemon mode

This commit is contained in:
Mike Cheng 2015-05-03 14:15:59 -04:00
parent 9c571f4c23
commit 338c337736
2 changed files with 9 additions and 9 deletions

View file

@ -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
}

16
main.go
View file

@ -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)
}