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 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)
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment