Documentation ¶
Overview ¶
Package config is a set of types for interacting with the gh configuration files. Note: This package is intended for use only in gh, any other use cases are subject to breakage and non-backwards compatible updates.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var Read = func() (*Config, error) {
once.Do(func() {
cfg, loadErr = load(generalConfigFile(), hostsConfigFile())
})
return cfg, loadErr
}
Read gh configuration files from the local file system and return a Config.
Functions ¶
func ConfigDir ¶
func ConfigDir() string
Config path precedence: GH_CONFIG_DIR, XDG_CONFIG_HOME, AppData (windows only), HOME.
func DataDir ¶
func DataDir() string
Data path precedence: XDG_DATA_HOME, LocalAppData (windows only), HOME.
Types ¶
type Config ¶
type Config struct {
// contains filtered or unexported fields
}
Config is a in memory representation of the gh configuration files. It can be thought of as map where entries consist of a key that correspond to either a string value or a map value, allowing for multi-level maps.
func ReadFromString ¶
ReadFromString takes a yaml string and returns a Config. Note: This is only used for testing, and should not be relied upon in production.
func (*Config) Get ¶
Get a string value from a Config. The keys argument is a sequence of key values so that nested entries can be retrieved. A undefined string will be returned if trying to retrieve a key that corresponds to a map value. Returns "", KeyNotFoundError if any of the keys can not be found.
func (*Config) Keys ¶
Keys enumerates a Config's keys. The keys argument is a sequence of key values so that nested map values can be have their keys enumerated. Returns nil, KeyNotFoundError if any of the keys can not be found.
type InvalidConfigFileError ¶
InvalidConfigFileError represents an error when trying to read a config file.
func (*InvalidConfigFileError) Error ¶
func (e *InvalidConfigFileError) Error() string
Allow InvalidConfigFileError to satisfy error interface.
func (*InvalidConfigFileError) Unwrap ¶
func (e *InvalidConfigFileError) Unwrap() error
Allow InvalidConfigFileError to be unwrapped.
type KeyNotFoundError ¶
type KeyNotFoundError struct {
Key string
}
KeyNotFoundError represents an error when trying to find a config key that does not exist.
func (*KeyNotFoundError) Error ¶
func (e *KeyNotFoundError) Error() string
Allow KeyNotFoundError to satisfy error interface.