-
Notifications
You must be signed in to change notification settings - Fork 0
/
config.go
49 lines (43 loc) · 996 Bytes
/
config.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
42
43
44
45
46
47
48
49
package main
import (
"encoding/json"
"os"
)
type Config struct {
OnlyColorPrefix bool `json:"only_color_prefix"`
ColorOutput bool `json:"color_output"`
Commands []Command `json:"commands"`
LogFile string `json:"log_file"`
SurpressOutput bool `json:"surpress_output"`
}
type Command struct {
Cwd string `json:"cwd"`
Cmd string `json:"cmd"`
}
const CONFIG_PATH = ".gleichzeitig/config.json"
var DEFAULT_CONFIG = Config{
OnlyColorPrefix: true,
ColorOutput: true,
Commands: []Command{
{
Cmd: "echo 'Hello World from command 1!'",
},
{
Cmd: "echo 'Hello World from command 2!'",
},
},
LogFile: "gleich.log",
SurpressOutput: false,
}
func getConfig() Config {
conf := Config{}
content, err := os.ReadFile(CONFIG_PATH)
if err != nil {
logErr("config not found, create one using 'gleichzeitig init'")
}
err = json.Unmarshal(content, &conf)
if err != nil {
logErr("config is not valid json")
}
return conf
}