Refactor: split in several files
This commit is contained in:
@@ -0,0 +1,34 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"os"
|
||||
"path/filepath"
|
||||
|
||||
"github.com/BurntSushi/toml"
|
||||
)
|
||||
|
||||
const defaultDoctolibLimit = 5
|
||||
|
||||
type DoctorConfig struct {
|
||||
Name string `toml:"name"`
|
||||
MotiveId string `toml:"motive_id"`
|
||||
AgendaId string `toml:"agenda_id"`
|
||||
PracticeId string `toml:"practice_id"`
|
||||
}
|
||||
|
||||
type Config struct {
|
||||
NtfyChannel string `toml:"ntfy_channel"`
|
||||
Doctors []DoctorConfig `toml:"doctor"`
|
||||
}
|
||||
|
||||
func loadConfig(path string) (Config, error) {
|
||||
var cfg Config
|
||||
_, err := toml.DecodeFile(path, &cfg)
|
||||
return cfg, err
|
||||
}
|
||||
|
||||
func defaultConfigFile() string {
|
||||
cwd, _ := os.Getwd()
|
||||
configPath := filepath.Join(cwd, "config.toml")
|
||||
return configPath
|
||||
}
|
||||
Reference in New Issue
Block a user