2018-10-13 03:23:55 +01:00
|
|
|
package config
|
|
|
|
|
|
|
|
import (
|
|
|
|
"path/filepath"
|
|
|
|
|
|
|
|
"github.com/BurntSushi/toml"
|
|
|
|
)
|
|
|
|
|
|
|
|
type WH40K struct {
|
|
|
|
DataDir string `toml:"data_dir"`
|
|
|
|
VideoPlayer []string `toml:"video_player"`
|
|
|
|
}
|
|
|
|
|
|
|
|
type Config struct {
|
2020-03-22 17:19:26 +00:00
|
|
|
WH40K `toml:"ordoor"`
|
2018-10-13 03:23:55 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
func Load(filename string) (*Config, error) {
|
|
|
|
var out Config
|
|
|
|
|
|
|
|
_, err := toml.DecodeFile(filename, &out)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
|
|
|
return &out, err
|
|
|
|
}
|
|
|
|
|
|
|
|
// TODO: case-insensitive lookup
|
|
|
|
func (c *Config) DataFile(path string) string {
|
|
|
|
return filepath.Join(c.DataDir, path)
|
|
|
|
}
|