Documentation
¶
Overview ¶
Package bindings declares, once, which command flags supply which configuration keys (contract:config.env, Constitution 6.1).
Purpose: flags.yaml binds a flag to its env key; exempt.yaml records the
flags that merely look like a key, each with a reason. The command registry fills flag.env from the bindings, `nself config explain` reads them, and the Configuration-Precedence wiki table is rendered from them.
Inputs: the embedded flags.yaml and exempt.yaml; the known key list
(config.KnownEnvVars) for validation.
Outputs: Bindings (Load), the registry map (FlagEnv), lookups, the
gate (Check) and the wiki table (RenderMarkdown).
Constraints: commands are canonical (v1.5) paths without "nself "; "." is
the root command. Pure: no I/O beyond the embedded files.
Index ¶
- Constants
- func CandidateKey(flag string, known []string) (string, bool)
- type Binding
- type Bindings
- func (b Bindings) Check(flags []FlagRef) error
- func (b Bindings) Exemption(command, flag string) (Exemption, bool)
- func (b Bindings) FlagEnv() map[string]map[string]string
- func (b Bindings) ForKey(key string) []Binding
- func (b Bindings) Lookup(command, flag string) (Binding, bool)
- func (b Bindings) RenderMarkdown() string
- type Exemption
- type FlagRef
Constants ¶
const ( // BeginMarker and EndMarker fence the generated region of the wiki page. BeginMarker = "<!-- BEGIN GENERATED: config-bindings (internal/config/bindings; do not hand edit) -->" EndMarker = "<!-- END GENERATED: config-bindings -->" )
const Root = "."
Root is the Command value of a flag declared on the root command.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Binding ¶
type Binding struct {
Command string `yaml:"command"`
Flag string `yaml:"flag"`
Key string `yaml:"key"`
}
Binding says that flag Flag of command Command supplies the value of Key.
type Bindings ¶
Bindings is the parsed declaration, sorted by command then flag.
func Parse ¶
Parse parses flags and exempt documents and validates them against known. Every violation is reported in one error.
func (Bindings) Check ¶
Check validates the bindings against the flags that exist. It reports an unbound candidate, a binding or exemption for a missing flag, and nothing else; key validity is Parse's job.
func (Bindings) FlagEnv ¶
FlagEnv returns the registry map: canonical command path to flag name to key.
func (Bindings) RenderMarkdown ¶
RenderMarkdown renders the bound-flags table and the exempt-flags table.