settings

package
v0.2.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 23, 2026 License: MIT Imports: 7 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ActionHandler

type ActionHandler interface {
	RunAction(ctx context.Context, actionID string) error
}

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

type SettingFileFilter struct {
	Name       string   `json:"name"`
	Extensions []string `json:"extensions"`
}

SettingFileFilter defines file dialog filters.

type SettingOption

type SettingOption struct {
	Label string `json:"label"`
	Value string `json:"value"`
}

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"
)

type SettingsStore

type SettingsStore interface {
	Get(key string) any
	GetString(key string) string
	GetBool(key string) bool
	GetInt(key string) int
	Set(key string, val any)
	Save() error
	GetDefaultPath() string
}

SettingsStore defines persistence and value access for plugin settings.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL