package core

import (
	"os"

	"gopkg.in/yaml.v2"
)

type Config struct {
	Gitea struct {
		InstanceURL string `yaml:"instance_url"`
		Owner       string `yaml:"owner"`
		Repository  string `yaml:"repository"`
		Token       string
	} `yaml:"gitea"`
	Language struct {
		OpeningOnSeparateLine bool   `yaml:"separate_opening"`
		Opening               string `yaml:"opening"`
		Continuation          string `yaml:"continuation"`
		Closing               string `yaml:"closing"`
	} `yaml:"language"`
}

func LoadConfig(config *Config, filename string) {
	configFile, err := os.Open(filename)
	ExitOnError(err)
	defer configFile.Close()

	decoder := yaml.NewDecoder(configFile)
	err = decoder.Decode(&config)
	ExitOnError(err)
}