Documentation ¶
Index ¶
- Constants
- type ConfigType
- type DefaultValue
- 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 KConfigPrompt
- type KeyValue
- type KeyValueMap
- func (kvm KeyValueMap) AllNoOrUnset(keys ...string) bool
- func (kvm KeyValueMap) AnyYes(keys ...string) bool
- func (kvm KeyValueMap) Get(key string) (*KeyValue, bool)
- func (kvm KeyValueMap) MarshalYAML() (interface{}, error)
- func (kvm KeyValueMap) Override(extra ...*KeyValue) KeyValueMap
- func (kvm KeyValueMap) OverrideBy(other KeyValueMap) KeyValueMap
- func (kvm KeyValueMap) RemoveEmpty() KeyValueMap
- func (kvm KeyValueMap) Resolve(lookupFn func(string) (string, bool)) KeyValueMap
- func (kvm KeyValueMap) Set(key, value string) KeyValueMap
- func (kvm KeyValueMap) Slice() []*KeyValue
- func (kvm KeyValueMap) String() string
- func (kvm KeyValueMap) Unset(key string) KeyValueMap
- type MenuKind
Constants ¶
const ( Yes = "y" Mod = "m" No = "n" Prefix = "CONFIG_" )
const ( MenuConfig = MenuKind("config") MenuGroup = MenuKind("group") MenuChoice = MenuKind("choice") MenuComment = MenuKind("comment") )
const ( TypeBool = ConfigType("bool") TypeTristate = ConfigType("tristate") TypeString = ConfigType("string") TypeInt = ConfigType("int") TypeHex = ConfigType("hex") )
const DotConfigFileName = ".config"
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ConfigType ¶
type ConfigType string
type DefaultValue ¶ added in v0.6.3
type DefaultValue struct { Value expr `json:"value,omitempty"` Condition expr `json:"condition,omitempty"` }
type DotConfigFile ¶
type DotConfigFile struct { Slice []*KeyValue Map KeyValueMap // 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) (*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 is the main menu Root *KConfigMenu `json:"root,omitempty"` // All config/menuconfig entries Configs map[string]*KConfigMenu `json:"configs,omitempty"` }
KConfigFile represents a parsed Kconfig file (including includes).
type KConfigMenu ¶
type KConfigMenu struct { // Kind represents the structure type, e.g. config/menu/choice/etc Kind MenuKind `json:"kind,omitempty"` // Type of menu element, e.g. tristate/bool/string/etc Type ConfigType `json:"type,omitempty"` // Name without CONFIG_ Name string `json:"name,omitempty"` // Sub-elements for menus Children []*KConfigMenu `json:"children,omitempty"` // Prompt is the 1-line description of the menu entry. Prompt KConfigPrompt `json:"prompt,omitempty"` // Help information about the menu item. Help string `json:"help,omitempty"` // Default value of the entry. Default DefaultValue `json:"default,omitempty"` // contains filtered or unexported fields }
KConfigMenu 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.
type KConfigPrompt ¶ added in v0.6.3
type KConfigPrompt struct { Text string `json:"text,omitempty"` Condition expr `json:"condition,omitempty"` }
type KeyValue ¶ added in v0.4.0
KeyValue represents a KConfig option with its name and its value.
func NewKeyValue ¶ added in v0.5.0
NewKeyValue returns a populated KeyValue by parsing the input line
func (*KeyValue) MarshalYAML ¶ added in v0.6.4
MarshalYAML makes KeyValue implement yaml.Marshaller
type KeyValueMap ¶ added in v0.4.0
KeyValueMap is a map of KeyValues
func NewKeyValueMapFromFile ¶ added in v0.5.0
func NewKeyValueMapFromFile(file string) (KeyValueMap, error)
NewKConfigValuesFromFile build a KConfigValues from a provided file path
func NewKeyValueMapFromMap ¶ added in v0.4.0
func NewKeyValueMapFromMap(values map[string]interface{}) (KeyValueMap, error)
NewKeyValueMapFromMap build a new Mapping from a set of KEY=VALUE strings
func NewKeyValueMapFromSlice ¶ added in v0.4.0
func NewKeyValueMapFromSlice(values ...interface{}) (KeyValueMap, error)
NewKeyValueMapFromSlice build a new Mapping from a set of KEY=VALUE strings
func (KeyValueMap) AllNoOrUnset ¶ added in v0.7.3
func (kvm KeyValueMap) AllNoOrUnset(keys ...string) bool
AllNoOrUnset accepts an input list of keys which are all checked against not having the value for "n" (meaning "no" or "false") or whether they are unset. If any of the keys are set to this value, this method returns false.
func (KeyValueMap) AnyYes ¶ added in v0.7.2
func (kvm KeyValueMap) AnyYes(keys ...string) bool
AnyYes accepts an input list of keys which are all checked against the KConfig value for "y" (meaning "yes" or "true"). If any of the keys are set to this value, this method returns true.
func (KeyValueMap) Get ¶ added in v0.5.0
func (kvm KeyValueMap) Get(key string) (*KeyValue, bool)
Get returns a KeyValue based on a key and a boolean result value if the entries was resolvable.
func (KeyValueMap) MarshalYAML ¶ added in v0.6.4
func (kvm KeyValueMap) MarshalYAML() (interface{}, error)
MarshalYAML makes KeyValueMap implement yaml.Marshaller
func (KeyValueMap) Override ¶ added in v0.4.0
func (kvm KeyValueMap) Override(extra ...*KeyValue) KeyValueMap
Override accepts a list of key value pairs and overrides the key in the map
func (KeyValueMap) OverrideBy ¶ added in v0.4.0
func (kvm KeyValueMap) OverrideBy(other KeyValueMap) KeyValueMap
OverrideBy update KeyValueMap with values from another KeyValueMap
func (KeyValueMap) RemoveEmpty ¶ added in v0.4.0
func (kvm KeyValueMap) RemoveEmpty() KeyValueMap
RemoveEmpty excludes keys that are not associated with a value
func (KeyValueMap) Resolve ¶ added in v0.4.0
func (kvm KeyValueMap) Resolve(lookupFn func(string) (string, bool)) KeyValueMap
Resolve update a KConfig for keys without value (`key`, but not `key=`)
func (KeyValueMap) Set ¶ added in v0.4.0
func (kvm KeyValueMap) Set(key, value string) KeyValueMap
Set a new key with specified value
func (KeyValueMap) Slice ¶ added in v0.4.0
func (kvm KeyValueMap) Slice() []*KeyValue
Slice returns the map as a slice
func (KeyValueMap) String ¶ added in v0.4.0
func (kvm KeyValueMap) String() string
String returns the serialized string representing a .config file
func (KeyValueMap) Unset ¶ added in v0.4.0
func (kvm KeyValueMap) Unset(key string) KeyValueMap
Unset a specific key