-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
41 lines (35 loc) · 784 Bytes
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
package main
import (
"io/ioutil"
"log"
"os"
"runtime"
"github.com/sequoiia/twivod/cmd"
"github.com/spf13/viper"
)
func main() {
viper.SetConfigName("twivod")
viper.SetConfigType("yaml")
viper.AddConfigPath("$HOME/.config")
viper.AddConfigPath(os.Getenv("APPDATA"))
err := viper.ReadInConfig()
if err != nil {
defaultConfig := []byte("twitchclientid: undefined\n")
if runtime.GOOS == "windows" {
err := ioutil.WriteFile(os.Getenv("APPDATA")+"\\twivod.yaml", defaultConfig, 0770)
if err != nil {
log.Fatal(err)
}
} else {
err := ioutil.WriteFile(os.Getenv("HOME")+"/.config/twivod.yaml", defaultConfig, 0770)
if err != nil {
log.Fatal(err)
}
}
err = viper.ReadInConfig()
if err != nil {
log.Fatal(err)
}
}
cmd.Execute()
}