mirror of
https://github.com/anotherhadi/spilltea.git
synced 2026-05-20 09:42:34 +02:00
e8e64eff12
Signed-off-by: Hadi <112569860+anotherhadi@users.noreply.github.com>
67 lines
1.0 KiB
Go
67 lines
1.0 KiB
Go
package plugins
|
|
|
|
import (
|
|
"sync"
|
|
|
|
lua "github.com/yuin/gopher-lua"
|
|
)
|
|
|
|
type HookConfig struct {
|
|
Sync bool
|
|
}
|
|
|
|
type Plugin struct {
|
|
Name string
|
|
FilePath string
|
|
Enabled bool
|
|
ConfigText string
|
|
|
|
L *lua.LState
|
|
mu sync.Mutex
|
|
hooks map[string]HookConfig
|
|
}
|
|
|
|
func (p *Plugin) HookNames() []string {
|
|
out := make([]string, 0, len(p.hooks))
|
|
for name := range p.hooks {
|
|
out = append(out, name)
|
|
}
|
|
return out
|
|
}
|
|
|
|
func (p *Plugin) HookConfig(name string) (HookConfig, bool) {
|
|
hc, ok := p.hooks[name]
|
|
return hc, ok
|
|
}
|
|
|
|
type Info struct {
|
|
Name string
|
|
FilePath string
|
|
Enabled bool
|
|
ConfigText string
|
|
Hooks map[string]HookConfig
|
|
}
|
|
|
|
func (p *Plugin) Info() Info {
|
|
hooks := make(map[string]HookConfig, len(p.hooks))
|
|
for k, v := range p.hooks {
|
|
hooks[k] = v
|
|
}
|
|
return Info{
|
|
Name: p.Name,
|
|
FilePath: p.FilePath,
|
|
Enabled: p.Enabled,
|
|
ConfigText: p.ConfigText,
|
|
Hooks: hooks,
|
|
}
|
|
}
|
|
|
|
type PluginNotifMsg struct {
|
|
Title string
|
|
Body string
|
|
}
|
|
|
|
type PluginQuitMsg struct {
|
|
Reason string
|
|
}
|