This commit is contained in:
Grail Finder
2025-07-31 10:46:07 +03:00
commit 757e948659
7 changed files with 410 additions and 0 deletions

29
config/config.go Normal file
View File

@@ -0,0 +1,29 @@
package config
import (
"fmt"
"github.com/BurntSushi/toml"
)
type Config struct {
CurrentAPI string `toml:"CurrentAPI"`
APIToken string `toml:"APIToken"`
QuestionsPath string `toml:"QuestionsPath"`
OutPath string `toml:"OutPath"`
}
func LoadConfigOrDefault(fn string) *Config {
if fn == "" {
fn = "config.toml"
}
config := &Config{}
_, err := toml.DecodeFile(fn, &config)
if err != nil {
fmt.Println("failed to read config from file, loading default", "error", err)
config.CurrentAPI = "http://localhost:8080/completion"
config.QuestionsPath = "data/questions.json"
config.OutPath = "data/out.json"
}
return config
}