From d07b70c2081a4411e5575817e2e2af771b17c270 Mon Sep 17 00:00:00 2001 From: Anatole Beuzon Date: Mon, 12 Feb 2018 14:27:03 +0100 Subject: [PATCH] feature: load config file using CLI argument --- main.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/main.go b/main.go index ac07466..70bf2ec 100644 --- a/main.go +++ b/main.go @@ -1,6 +1,7 @@ package main import ( + "flag" "fmt" "log" "net" @@ -10,11 +11,11 @@ import ( "github.com/google/gopacket/pcap" ) -const configPath = "./config.toml" - func main() { // Read config file and generate mDNS forwarding maps - cfg, err := readConfig(configPath) + configPath := flag.String("config", "", "Config file in TOML format") + flag.Parse() + cfg, err := readConfig(*configPath) if err != nil { log.Fatalf("Could not read configuration: %v", err) }