From b49c4f1206521f7ae7fea46efc383e8d31fb007d Mon Sep 17 00:00:00 2001 From: Silvan Jegen Date: Tue, 21 Feb 2017 06:55:01 +0100 Subject: Use a config flag --- main.go | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/main.go b/main.go index ec7e6b2..c6eec0b 100644 --- a/main.go +++ b/main.go @@ -2,6 +2,7 @@ package main import ( "bufio" + "flag" "fmt" "os" @@ -9,9 +10,13 @@ import ( ) func main() { - f, err := os.Open("stasher.cfg") + var configpath *string + configpath = flag.String("c", "stasher.cfg", "Path to config file") + flag.Parse() + + f, err := os.Open(*configpath) if err != nil { - fmt.Fprintf(os.Stderr, "Could not open config file 'stasher.cfg': %q\n", err) + fmt.Fprintf(os.Stderr, "Could not open config file %q: %q\n", *configpath, err) os.Exit(1) } -- cgit v1.2.3