summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSilvan Jegen <s.jegen@gmail.com>2017-02-21 06:55:01 +0100
committerSilvan Jegen <s.jegen@gmail.com>2017-02-21 06:55:01 +0100
commitb49c4f1206521f7ae7fea46efc383e8d31fb007d (patch)
treec37b77c06d02df847d9021923dcb81975682a635
parentcee74e4f30277d737ac6a54f016e15f1e831212a (diff)
Use a config flag
-rw-r--r--main.go9
1 files 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)
}