2021-09-11 22:24:39 +02:00
|
|
|
package core
|
2021-09-11 20:25:20 +02:00
|
|
|
|
|
|
|
import (
|
|
|
|
"os"
|
|
|
|
|
|
|
|
"gopkg.in/yaml.v2"
|
|
|
|
)
|
|
|
|
|
|
|
|
type Config struct {
|
|
|
|
Gitea struct {
|
|
|
|
InstanceURL string `yaml:"instance_url"`
|
|
|
|
Owner string `yaml:"owner"`
|
|
|
|
Repository string `yaml:"repository"`
|
2021-09-11 22:24:39 +02:00
|
|
|
Token string
|
2021-09-11 20:25:20 +02:00
|
|
|
} `yaml:"gitea"`
|
|
|
|
Language struct {
|
2021-09-11 23:34:25 +02:00
|
|
|
OnSeparateLine bool `yaml:"on_separate_line"`
|
|
|
|
Opening string `yaml:"opening"`
|
|
|
|
Continuation string `yaml:"continuation"`
|
|
|
|
Closing string `yaml:"closing"`
|
2021-09-11 20:25:20 +02:00
|
|
|
} `yaml:"language"`
|
|
|
|
}
|
|
|
|
|
|
|
|
func LoadConfig(config *Config, filename string) {
|
|
|
|
configFile, err := os.Open(filename)
|
2021-12-07 00:25:29 +01:00
|
|
|
ExitOnError("Couldn't open config file", err)
|
2021-09-11 20:25:20 +02:00
|
|
|
defer configFile.Close()
|
|
|
|
|
|
|
|
decoder := yaml.NewDecoder(configFile)
|
|
|
|
err = decoder.Decode(&config)
|
2021-12-07 00:25:29 +01:00
|
|
|
ExitOnError("Couldn't decode config file", err)
|
2021-09-11 20:25:20 +02:00
|
|
|
}
|