You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
35 lines
588 B
35 lines
588 B
package config
|
|
|
|
import (
|
|
"flag"
|
|
"log"
|
|
"github.com/BurntSushi/toml"
|
|
)
|
|
|
|
type config struct {
|
|
Test int
|
|
ConfigPath string
|
|
}
|
|
|
|
var Settings config
|
|
|
|
func parseFlags(c *config) {
|
|
flag.StringVar(&c.ConfigPath, "config", ".ozai.toml", ".ozai.toml to load")
|
|
flag.Parse()
|
|
}
|
|
|
|
func Load() {
|
|
parseFlags(&Settings)
|
|
|
|
metadata, err := toml.DecodeFile(Settings.ConfigPath, &Settings)
|
|
|
|
if err != nil {
|
|
log.Fatalf("error loading config.toml: %v", err)
|
|
}
|
|
|
|
bad_keys := metadata.Undecoded()
|
|
|
|
if len(bad_keys) > 0 {
|
|
log.Fatalf("unknown configuration keys: %v", bad_keys);
|
|
}
|
|
}
|
|
|