Documentation ¶
Index ¶
Constants ¶
const (
// PreferencesName is the name for the preferences file.
PreferencesName = "preferences.json"
)
Variables ¶
This section is empty.
Functions ¶
func WritePreferences ¶
func WritePreferences(ctx context.Context, config Config, preferences Preferences) error
WritePreferences writes preferences to the filesystem.
Types ¶
type Condition ¶
type Condition struct { LHS string `json:"lhs"` RHS string `json:"rhs"` Op OperationType `json:"op"` }
Condition is a condition. Conditions are used to determine if an element is enabled.
type Config ¶
type Config interface { // DataDirectory is the data directory. DataDirectory() string }
Config is configuration for preferences.
type Element ¶
type Element struct { Name string `json:"name"` Value string `json:"value"` Type string `json:"type"` DisableConditions []Condition `json:"disableConditions,omitempty"` Config interface{} `json:"config"` }
Element is an element in a section.
type OperationType ¶
type OperationType string
OperationType is an operation type. It is used in Condition to determine if an element is enabled.
const ( // OperationTypeString is an equal operation. OperationTypeString OperationType = "Equal" )
type PreferencePanel ¶
type PreferencePanel struct { Name string `json:"name"` Sections []PreferenceSection `json:"sections,omitempty"` }
PreferencePanel is a preference panel.
type PreferenceSection ¶
type PreferenceSection struct { Name string `json:"name"` Elements []Element `json:"elements,omitempty"` }
PreferenceSection is a section in a preference panel.
type Preferences ¶
type Preferences struct { Version string `json:"version"` Panels []PreferencePanel `json:"panels,omitempty"` UpdateName string `json:"updateName"` }
Preferences are preferences.
func CreateOrOpenPreferences ¶
func CreateOrOpenPreferences(ctx context.Context, config Config) (Preferences, error)
CreateOrOpenPreferences creates or opens an existing preferences file.
func (*Preferences) Update ¶
func (p *Preferences) Update(values map[string]string)
Update updates preferences given a set of a values.
type RadioConfig ¶
type RadioConfig struct {
Values []RadioValue `json:"values"`
}
RadioConfig is configuration for a radio element.
type RadioValue ¶
RadioValue is an individual radio value.
type TextConfig ¶
TextConfig is configuration for a text element.