amend ConfigLoader load style by default & update Cfg interface
This commit is contained in:
parent
1751c83804
commit
bd9a98cdc8
|
@ -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 {
|
||||
|
|
Loading…
Reference in New Issue
Block a user