Help us shape the future of Go! Take the 2026 Go Developer Survey

bindings

package
v1.4.15 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 19, 2026 License: MIT Imports: 10 Imported by: 0

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

View Source
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 -->"
)
View Source
const Root = "."

Root is the Command value of a flag declared on the root command.

Variables

This section is empty.

Functions

func CandidateKey

func CandidateKey(flag string, known []string) (string, bool)

CandidateKey reports the known key a flag name looks like: the upper-snake name, with or without the NSELF_ prefix.

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

type Bindings struct {
	Flags  []Binding
	Exempt []Exemption
}

Bindings is the parsed declaration, sorted by command then flag.

func Load

func Load() (Bindings, error)

Load parses and validates the embedded declaration against config.KnownEnvVars().

func Parse

func Parse(flags, exempt []byte, known []string) (Bindings, error)

Parse parses flags and exempt documents and validates them against known. Every violation is reported in one error.

func (Bindings) Check

func (b Bindings) Check(flags []FlagRef) error

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) Exemption

func (b Bindings) Exemption(command, flag string) (Exemption, bool)

Exemption returns the exemption of one flag.

func (Bindings) FlagEnv

func (b Bindings) FlagEnv() map[string]map[string]string

FlagEnv returns the registry map: canonical command path to flag name to key.

func (Bindings) ForKey

func (b Bindings) ForKey(key string) []Binding

ForKey lists the bindings of one key, in command order.

func (Bindings) Lookup

func (b Bindings) Lookup(command, flag string) (Binding, bool)

Lookup returns the binding of one flag.

func (Bindings) RenderMarkdown

func (b Bindings) RenderMarkdown() string

RenderMarkdown renders the bound-flags table and the exempt-flags table.

type Exemption

type Exemption struct {
	Command string `yaml:"command"`
	Flag    string `yaml:"flag"`
	Reason  string `yaml:"reason"`
}

Exemption records a flag that looks like a key and is not one.

type FlagRef

type FlagRef struct {
	Command string
	Flag    string
}

FlagRef names one declared flag of one command (canonical path, or Root).

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL