subsyt/internal/config/config.go
Viktor Varland 1aa4e66c7e
All checks were successful
build / build (push) Successful in 1m22s
feat: support configuring the bgutil server
2025-04-14 13:06:07 +02:00

50 lines
830 B
Go

package config
import (
"log"
"os"
toml "github.com/pelletier/go-toml/v2"
)
type Provider struct {
Url string
Throttle int
Range string
After_date string
Cmd string
Cookies_file string
Opml_file string
Quality string
Output_path_template string
Po_token string
Verbose bool
Bgutil_server string
}
type Config struct {
Out_dir string
Provider map[string]Provider
Dry_run bool
Daemon bool
}
func Load(filepath string) (Config, error) {
data, err := os.ReadFile(filepath)
if err != nil {
panic(err)
}
cfg := Config{}
err = toml.Unmarshal(data, &cfg)
if err != nil {
panic(err)
}
log.Println("Loaded config:")
log.Printf("%+v\n", cfg)
return cfg, err
}