mirror of
https://github.com/hrfee/jfa-go.git
synced 2026-01-18 16:47:42 +01:00
config: migrate to new yaml format
config-base.yaml is almost identical to json version, except there's no "order" field, as "sections" and "settings" fields are now lists themselves and so Go can parse the correct order. As such, removed enumerate_config.py. Also, rewrote scripts/generate_ini.py in Go as scripts/ini/. Config structure in Go form is now in common/config.go, and is used by jfa-go and the ini script. app.configBase is now untouched once read from config-base.yaml, and instead copied to and patched in app.patchedConfig. Patching occurs at program start and config modification, so GetConfig is now just a couple of lines. Discord role patching still occurs in GetConfig, as the available roles can change regularly. Also added new "Disabled" field to sections, to avoid the nightmare of deleting from an array.
This commit is contained in:
37
models.go
37
models.go
@@ -212,43 +212,6 @@ type errorListDTO map[string]map[string]string
|
||||
|
||||
type configDTO map[string]interface{}
|
||||
|
||||
// Below are for sending config
|
||||
|
||||
type meta struct {
|
||||
Name string `json:"name"`
|
||||
Description string `json:"description"`
|
||||
Advanced bool `json:"advanced,omitempty"`
|
||||
DependsTrue string `json:"depends_true,omitempty"`
|
||||
DependsFalse string `json:"depends_false,omitempty"`
|
||||
WikiLink string `json:"wiki_link,omitempty"`
|
||||
}
|
||||
|
||||
type setting struct {
|
||||
Name string `json:"name"`
|
||||
Description string `json:"description"`
|
||||
Required bool `json:"required"`
|
||||
Advanced bool `json:"advanced,omitempty"`
|
||||
RequiresRestart bool `json:"requires_restart"`
|
||||
Type string `json:"type"` // Type (string, number, bool, etc.)
|
||||
Value interface{} `json:"value"`
|
||||
Options [][2]string `json:"options,omitempty"`
|
||||
DependsTrue string `json:"depends_true,omitempty"` // If specified, this field is enabled when the specified bool setting is enabled.
|
||||
DependsFalse string `json:"depends_false,omitempty"` // If specified, opposite behaviour of DependsTrue.
|
||||
Style string `json:"style,omitempty"`
|
||||
Deprecated bool `json:"deprecated,omitempty"`
|
||||
}
|
||||
|
||||
type section struct {
|
||||
Meta meta `json:"meta"`
|
||||
Order []string `json:"order"`
|
||||
Settings map[string]setting `json:"settings"`
|
||||
}
|
||||
|
||||
type settings struct {
|
||||
Order []string `json:"order"`
|
||||
Sections map[string]section `json:"sections"`
|
||||
}
|
||||
|
||||
type langDTO map[string]string
|
||||
|
||||
type emailListDTO map[string]emailListEl
|
||||
|
||||
Reference in New Issue
Block a user