mirror of
https://github.com/anotherhadi/spilltea.git
synced 2026-05-21 18:12:33 +02:00
Change default plugin's config in global config
Signed-off-by: Hadi <112569860+anotherhadi@users.noreply.github.com>
This commit is contained in:
@@ -66,9 +66,16 @@ func (pf *PluginsFile) get(id string) (enabled bool, config string, found bool)
|
||||
return e.Enable, string(raw), true
|
||||
}
|
||||
|
||||
func (pf *PluginsFile) register(id string, defaultEnabled bool) {
|
||||
func (pf *PluginsFile) register(id string, defaultEnabled bool, configText string) {
|
||||
if _, ok := pf.data.Plugins[id]; !ok {
|
||||
pf.data.Plugins[id] = pluginFileEntry{Enable: defaultEnabled}
|
||||
entry := pluginFileEntry{Enable: defaultEnabled}
|
||||
if configText != "" {
|
||||
var parsed interface{}
|
||||
if err := yaml.Unmarshal([]byte(configText), &parsed); err == nil {
|
||||
entry.Config = parsed
|
||||
}
|
||||
}
|
||||
pf.data.Plugins[id] = entry
|
||||
_ = pf.save()
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user