amend ConfigLoader load style by default & update Cfg interface

This commit is contained in:
Mahdi Abu Yasmine 2023-11-05 13:01:17 +01:00
parent 1751c83804
commit bd9a98cdc8
1 changed files with 13 additions and 1 deletions

View File

@ -6,11 +6,14 @@ import (
"regexp"
"strings"
"gitea.meta-tech.academy/go/core/style"
"gopkg.in/yaml.v3"
)
type Cfg interface {
GetVar() []VarConfig
GetStylesDef() []string
SetStyles(*style.Styles)
}
type VarConfig struct {
@ -38,7 +41,16 @@ func LoadConfig(path string, out Cfg, varPattern *VarPattern) {
cl.Config = out
cl.parse()
cl.refstr = []*reflect.Value{}
// cl.setConfigPtr(outi)
cl.buildStyles(out)
}
func (cl *ConfigLoader) buildStyles(out Cfg) {
styles := style.NewStyles()
for _, def := range out.GetStylesDef() {
s := style.NewStyleByDef(def)
styles.List[s.Name] = s
}
out.SetStyles(styles)
}
func (cl *ConfigLoader) findVarName(match string) string {