Commit 7554f9f4 authored by Erick Hitter's avatar Erick Hitter
Browse files

Move config to a flag

parent 918776dc
package main package main
import ( import (
"flag"
"fmt" "fmt"
"github.com/joshbetz/config" "github.com/joshbetz/config"
"io/ioutil" "io/ioutil"
...@@ -27,7 +28,17 @@ func init() { ...@@ -27,7 +28,17 @@ func init() {
logger.Println("PINGING dyndnsd ENDPOINT") logger.Println("PINGING dyndnsd ENDPOINT")
// Configuration // Configuration
cfg = config.New("config.json") var configPath string
flag.StringVar(&configPath, "config", "", "Config file path")
flag.Parse()
if _, err := os.Stat(configPath); os.IsNotExist(err) {
fmt.Println("Config path does not exist. Aborting!\n")
flag.Usage()
os.Exit(3)
}
cfg = config.New(configPath)
cfg.Get("ipv4_endpoint", &ipv4Endpoint) cfg.Get("ipv4_endpoint", &ipv4Endpoint)
cfg.Get("ipv6_endpoint", &ipv6Endpoint) cfg.Get("ipv6_endpoint", &ipv6Endpoint)
} }
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment