Documentation
¶
Overview ¶
Package settings stores plugin options declared with plugin.SettingsSpec. Values live in data/<plugin>/settings.json; the companion bot edits them.
Index ¶
- Constants
- func Validate(spec *plugin.SettingsSpec) error
- type Registry
- type Store
- func (s *Store) Bool(key string) bool
- func (s *Store) Get(key string) any
- func (s *Store) Int(key string) int
- func (s *Store) IsDefault(key string) bool
- func (s *Store) Reset(key string) error
- func (s *Store) Set(key string, value any) error
- func (s *Store) SetText(key, text string) error
- func (s *Store) Setting(key string) (*plugin.Setting, bool)
- func (s *Store) Spec() *plugin.SettingsSpec
- func (s *Store) String(key string) string
Constants ¶
const FileName = "settings.json"
FileName is the per-plugin settings file inside data/<plugin>/.
Variables ¶
This section is empty.
Functions ¶
func Validate ¶
func Validate(spec *plugin.SettingsSpec) error
Validate checks a spec before it is registered.
Types ¶
type Registry ¶
type Registry struct {
// contains filtered or unexported fields
}
Registry holds every registered settings spec.
func NewRegistry ¶
NewRegistry keeps settings under root/<plugin>/settings.json.
func (*Registry) Register ¶
func (r *Registry) Register(spec *plugin.SettingsSpec) (*Store, error)
Register validates spec, loads saved values and returns the store. A plugin registers once per load; unloading it frees the name again.
func (*Registry) Unregister ¶
Unregister drops a plugin's spec. Saved values stay on disk.
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
Store is one plugin's settings. It implements plugin.Settings.
func (*Store) SetText ¶
SetText parses typed text for a text or number setting, runs Validate and stores it. The error text is meant for the owner.