Documentation ¶
Index ¶
- Constants
- type ConfigType
- type DotConfigFile
- func (cf *DotConfigFile) Clone() *DotConfigFile
- func (cf *DotConfigFile) ModToNo()
- func (cf *DotConfigFile) ModToYes()
- func (cf *DotConfigFile) Serialize() []byte
- func (cf *DotConfigFile) Set(name, val string)
- func (cf *DotConfigFile) Unset(name string)
- func (cf *DotConfigFile) Value(name string) string
- type KConfigFile
- type KConfigMenu
- type KConfigValue
- type KConfigValues
- func (kco KConfigValues) OverrideBy(other KConfigValues) KConfigValues
- func (kco KConfigValues) RemoveEmpty() KConfigValues
- func (kco KConfigValues) Resolve(lookupFn func(string) (string, bool)) KConfigValues
- func (kco KConfigValues) Set(key, value string) KConfigValues
- func (kco KConfigValues) String() string
- func (kco KConfigValues) Unset(key string) KConfigValues
- type MenuKind
Constants ¶
const ( Yes = "y" Mod = "m" No = "---===[[[is not set]]]===---" // to make it more obvious when some code writes it directly Prefix = "CONFIG_" )
const DotConfigFileName = ".config"
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ConfigType ¶
type ConfigType int
const ( TypeBool ConfigType TypeTristate TypeString TypeInt TypeHex )
type DotConfigFile ¶
type DotConfigFile struct { Configs []*KConfigValue Map map[string]*KConfigValue // duplicates Configs for convenience // contains filtered or unexported fields }
DotConfigFile represents a parsed .config file. It should not be modified directly, only by means of calling methods. The only exception is Config.Value which may be modified directly. Note: config names don't include CONFIG_ prefix, here and in other public interfaces, users of this package should never mention CONFIG_. Use Yes/Mod/No consts to check for/set config to particular values.
func ParseConfig ¶
func ParseConfig(file string) (*DotConfigFile, error)
func ParseConfigData ¶
func ParseConfigData(data []byte, file string) (*DotConfigFile, error)
func (*DotConfigFile) Clone ¶
func (cf *DotConfigFile) Clone() *DotConfigFile
func (*DotConfigFile) ModToNo ¶
func (cf *DotConfigFile) ModToNo()
func (*DotConfigFile) ModToYes ¶
func (cf *DotConfigFile) ModToYes()
func (*DotConfigFile) Serialize ¶
func (cf *DotConfigFile) Serialize() []byte
func (*DotConfigFile) Set ¶
func (cf *DotConfigFile) Set(name, val string)
Set changes config value, or adds it if it's not yet present.
func (*DotConfigFile) Unset ¶
func (cf *DotConfigFile) Unset(name string)
Unset sets config value to No, if it's present in the config.
func (*DotConfigFile) Value ¶
func (cf *DotConfigFile) Value(name string) string
Value returns config value, or No if it's not present at all.
type KConfigFile ¶
type KConfigFile struct { Root *KConfigMenu // mainmenu Configs map[string]*KConfigMenu // only config/menuconfig entries }
KConfigFile represents a parsed Kconfig file (including includes).
func Parse ¶
func Parse(file string) (*KConfigFile, error)
type KConfigMenu ¶
type KConfigMenu struct { Kind MenuKind // config/menu/choice/etc Type ConfigType // tristate/bool/string/etc Name string // name without CONFIG_ Elems []*KConfigMenu // sub-elements for menus Parent *KConfigMenu // parent menu, non-nil for everythign except for mainmenu // contains filtered or unexported fields }
Menu represents a single hierarchical menu or config.
func (*KConfigMenu) DependsOn ¶
func (m *KConfigMenu) DependsOn() map[string]bool
DependsOn returns all transitive configs this config depends on.
func (*KConfigMenu) Prompt ¶
func (m *KConfigMenu) Prompt() string
type KConfigValue ¶
type KConfigValues ¶
type KConfigValues map[string]*KConfigValue
KConfigValues is a map of KConfigValue
func NewKConfigValuesFromMap ¶
func NewKConfigValuesFromMap(values map[string]interface{}) KConfigValues
NewKConfigValuesFromMap build a new Mapping from a set of KEY=VALUE strings
func NewKConfigValuesFromSlice ¶
func NewKConfigValuesFromSlice(values ...interface{}) KConfigValues
NewKConfigValuesFromSlice build a new Mapping from a set of KEY=VALUE strings
func (KConfigValues) OverrideBy ¶
func (kco KConfigValues) OverrideBy(other KConfigValues) KConfigValues
OverrideBy update KConfigValues with values from another KConfigValues
func (KConfigValues) RemoveEmpty ¶
func (kco KConfigValues) RemoveEmpty() KConfigValues
RemoveEmpty excludes keys that are not associated with a value
func (KConfigValues) Resolve ¶
func (kco KConfigValues) Resolve(lookupFn func(string) (string, bool)) KConfigValues
Resolve update a KConfig for keys without value (`key`, but not `key=`)
func (KConfigValues) Set ¶
func (kco KConfigValues) Set(key, value string) KConfigValues
Set a new key with specified value
func (KConfigValues) String ¶
func (kco KConfigValues) String() string
String returns the serialized string representing a .config file
func (KConfigValues) Unset ¶
func (kco KConfigValues) Unset(key string) KConfigValues
Unset a specific key