Documentation ¶
Overview ¶
Package persistence manages the persistent user profile used by the command application infrastructure. This includes automatically reading any profile in as part of startup, and of updating the profile as needed.
Index ¶
- Constants
- Variables
- func Delete(key string) error
- func DeleteProfile(key string) error
- func Exists(key string) bool
- func Get(key string) string
- func GetBool(key string) bool
- func GetInt(key string) int
- func GetUsingList(key string, values ...string) int
- func Keys() []string
- func Load(application string, name string) error
- func Save() error
- func Set(key string, value string)
- func SetDefault(key string, value string)
- func UseProfile(name string)
- type Configuration
Constants ¶
const ProfileDirectory = ".org.fernwood"
ProfileDirectory is the name of the invisible directory that is created in the user's home directory to host configuration data.
Variables ¶
var Configurations map[string]Configuration
Configurations is a map keyed by the configuration name for each configuration in the config file.
var DefaultConfiguration = i18n.L("Default.configuration")
DefaultConfiguration is a localized string that contains the local text for "Default configuration".
var ProfileDirty = false
ProfileDirty is set to true when a key value is written or deleted, which tells us to rewrite the profile. If false, then no update is required.
var ProfileFile = "config.json"
ProfileFile is the name of the configuration file that contains the profiles.
var ProfileName = "default"
ProfileName is the name of the configuration being used. The default configuration is always named "default".
Functions ¶
func DeleteProfile ¶
func Get ¶
Get gets a profile entry in the current configuration structure. If the key does not exist, an empty string is returned.
func GetBool ¶
GetBool returns the boolean value of a profile string. If the string is "Y", "YES", "1", or "true" then the value returns true.
func GetUsingList ¶
Get a key value, and compare it to a list of provided values. If it matches one of the items in the list, then the position in the list (one-based) is returned. If the value is not in the list at all, a result of 0 is returned.
func Keys ¶
func Keys() []string
Keys returns the list of keys in the profile as an array of strings.
func SetDefault ¶
SetDefault puts a profile entry in the current Configuration structure. It is different than Set() in that it doesn't mark the value as dirty, so no need to update on account of this setting.
func UseProfile ¶
func UseProfile(name string)
UseProfile specifies the name of the profile to use, if other than the default.
Types ¶
type Configuration ¶
type Configuration struct { Description string `json:"description,omitempty"` ID string `json:"id,omitempty"` Items map[string]string `json:"items"` }
Configuration describes what is known about a configuration.
var CurrentConfiguration *Configuration
CurrentConfiguration describes the current configuration that is active.