Skip to content
Snippets Groups Projects
Commit 7554f9f4 authored by Erick Hitter's avatar Erick Hitter
Browse files

Move config to a flag

parent 918776dc
No related branches found
No related tags found
No related merge requests found
package main
import (
"flag"
"fmt"
"github.com/joshbetz/config"
"io/ioutil"
......@@ -27,7 +28,17 @@ func init() {
logger.Println("PINGING dyndnsd ENDPOINT")
// 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("ipv6_endpoint", &ipv6Endpoint)
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment