diff options
author | Silvan Jegen <s.jegen@gmail.com> | 2017-02-21 06:55:01 +0100 |
---|---|---|
committer | Silvan Jegen <s.jegen@gmail.com> | 2017-02-21 06:55:01 +0100 |
commit | b49c4f1206521f7ae7fea46efc383e8d31fb007d (patch) | |
tree | c37b77c06d02df847d9021923dcb81975682a635 | |
parent | cee74e4f30277d737ac6a54f016e15f1e831212a (diff) |
Use a config flag
-rw-r--r-- | main.go | 9 |
1 files changed, 7 insertions, 2 deletions
@@ -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) } |