aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.gitignore2
-rw-r--r--cmd/termsonic/main.go42
2 files changed, 43 insertions, 1 deletions
diff --git a/.gitignore b/.gitignore
index 8a0f2d2..02915e9 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,3 +1,3 @@
1launch.json 1launch.json
2termsonic 2/termsonic
3termsonic.exe 3termsonic.exe
diff --git a/cmd/termsonic/main.go b/cmd/termsonic/main.go
new file mode 100644
index 0000000..57687d9
--- /dev/null
+++ b/cmd/termsonic/main.go
@@ -0,0 +1,42 @@
1package main
2
3import (
4 "flag"
5 "fmt"
6 "os"
7
8 "git.sixfoisneuf.fr/termsonic/src"
9)
10
11var (
12 configFile = flag.String("config", "", "Path to the configuration file")
13)
14
15func main() {
16 flag.Parse()
17
18 var cfg *src.Config
19 var err error
20 if *configFile == "" {
21 cfg, err = src.LoadDefaultConfig()
22 if err != nil {
23 fmt.Printf("Could not start termsonic: %v", err)
24 os.Exit(1)
25 }
26 } else {
27 f, err := os.Open(*configFile)
28 if err != nil {
29 fmt.Printf("Could not read configuration file: %v", err)
30 os.Exit(1)
31 }
32 f.Close()
33
34 cfg, err = src.LoadConfigFromFile(*configFile)
35 if err != nil {
36 fmt.Printf("Error loading configuration file: %v", err)
37 os.Exit(1)
38 }
39 }
40
41 src.Run(cfg)
42}