Documentation
¶
Index ¶
- type ActionHandler
- type JSONSettingsStore
- func (s *JSONSettingsStore) Get(key string) any
- func (s *JSONSettingsStore) GetBool(key string) bool
- func (s *JSONSettingsStore) GetDefaultPath() string
- func (s *JSONSettingsStore) GetInt(key string) int
- func (s *JSONSettingsStore) GetString(key string) string
- func (s *JSONSettingsStore) Save() error
- func (s *JSONSettingsStore) Set(key string, val any)
- type SettingAction
- type SettingField
- type SettingFileFilter
- type SettingOption
- type SettingType
- type SettingsStore
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ActionHandler ¶
ActionHandler allows a plugin to handle action button clicks in settings.
type JSONSettingsStore ¶
type JSONSettingsStore struct {
// contains filtered or unexported fields
}
JSONSettingsStore manages reading and atomic writing of settings to a JSON file.
func NewJSONSettingsStore ¶
func NewJSONSettingsStore(filePath string, fields []SettingField) (*JSONSettingsStore, error)
NewJSONSettingsStore initializes a store with schema defaults and loads existing data from disk.
func (*JSONSettingsStore) Get ¶
func (s *JSONSettingsStore) Get(key string) any
Get returns the configured value or default.
func (*JSONSettingsStore) GetBool ¶
func (s *JSONSettingsStore) GetBool(key string) bool
GetBool returns setting value as boolean.
func (*JSONSettingsStore) GetDefaultPath ¶
func (s *JSONSettingsStore) GetDefaultPath() string
GetDefaultPath returns the directory containing the settings file, which is the plugin's default data directory.
func (*JSONSettingsStore) GetInt ¶
func (s *JSONSettingsStore) GetInt(key string) int
GetInt returns setting value as integer.
func (*JSONSettingsStore) GetString ¶
func (s *JSONSettingsStore) GetString(key string) string
GetString returns setting value as string.
func (*JSONSettingsStore) Save ¶
func (s *JSONSettingsStore) Save() error
Save writes settings atomically to disk.
func (*JSONSettingsStore) Set ¶
func (s *JSONSettingsStore) Set(key string, val any)
Set updates a setting value in memory.
type SettingAction ¶
type SettingAction struct {
ID string `json:"id"`
Label string `json:"label"`
Description string `json:"description"`
}
SettingAction represents a triggerable action attached to a field.
type SettingField ¶
type SettingField struct {
Key string `json:"key"`
Type SettingType `json:"type"`
Label string `json:"label"`
Description string `json:"description,omitempty"`
Placeholder string `json:"placeholder,omitempty"`
Default any `json:"default,omitempty"`
Required bool `json:"required,omitempty"`
Filter *SettingFileFilter `json:"filter,omitempty"`
Options []SettingOption `json:"options,omitempty"`
Action *SettingAction `json:"action,omitempty"`
}
SettingField declares one configurable setting schema entry.
type SettingFileFilter ¶
SettingFileFilter defines file dialog filters.
type SettingOption ¶
SettingOption defines a selectable choice in a dropdown.
type SettingType ¶
type SettingType string
SettingType identifies the input kind for a setting field.
const ( SettingText SettingType = "text" SettingNumber SettingType = "number" SettingToggle SettingType = "toggle" SettingDropdown SettingType = "dropdown" SettingFile SettingType = "file_picker" SettingDirectory SettingType = "directory_picker" )