Documentation
¶
Overview ¶
Package bkl implements a layered configuration language parser.
- Language & tool documentation: https://bkl.gopatchy.io/
- Go library source: https://github.com/gopatchy/bkl
- Go library documentation: https://pkg.go.dev/github.com/gopatchy/bkl
Index ¶
- func Diff(fx fs.FS, srcPath, dstPath string, rootPath string, workingDir string, ...) ([]byte, error)
- func Evaluate(fx fs.FS, files []string, rootPath string, workingDir string, ...) ([]byte, error)
- func FormatOutput(data any, format *string, paths ...*string) ([]byte, error)
- func GetTests() (map[string]*TestCase, error)
- func Intersect(fx fs.FS, paths []string, rootPath string, workingDir string, selector string, ...) ([]byte, error)
- func Required(fx fs.FS, path string, rootPath string, workingDir string, format *string, ...) ([]byte, error)
- type CompareResult
- type DocExample
- type DocItem
- type DocLayer
- type DocSection
- type DocSideBySide
- type TestCase
- type TreeResult
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Evaluate ¶ added in v1.0.52
func Evaluate(fx fs.FS, files []string, rootPath string, workingDir string, env map[string]string, format *string, sortPath string, paths ...*string) ([]byte, error)
Evaluate processes the specified files and returns the formatted output. If format is nil, it infers the format from the paths parameter (output path first, then input files). If env is nil, it uses the current OS environment.
func FormatOutput ¶ added in v1.0.52
FormatOutput marshals the given data to the specified format. If format is nil or points to an empty string, it looks at the provided paths and uses the file extension of the first non-nil path as the format. Returns the marshaled bytes or an error if the format is unknown or marshaling fails.
func Required ¶ added in v1.0.52
func Required(fx fs.FS, path string, rootPath string, workingDir string, format *string, paths ...*string) ([]byte, error)
Required loads a file and returns only the required fields and their ancestors. It processes all documents in the file, outputting one document for each input document. The file is loaded directly without processing, matching bklr behavior. If format is nil, it infers the format from the paths parameter.
Types ¶
type CompareResult ¶ added in v1.0.52
type DocExample ¶ added in v1.0.52
type DocItem ¶ added in v1.0.52
type DocItem struct {
Content string `yaml:"content,omitempty"`
Example *DocExample `yaml:"example,omitempty"`
Code *DocLayer `yaml:"code,omitempty"`
SideBySide *DocSideBySide `yaml:"side_by_side,omitempty"`
}
type DocSection ¶ added in v1.0.52
type DocSection struct {
ID string `yaml:"id"`
Title string `yaml:"title"`
Items []DocItem `yaml:"items"`
Source string `yaml:"-"`
}
func GetDocSections ¶ added in v1.0.52
func GetDocSections() ([]DocSection, error)
type DocSideBySide ¶ added in v1.0.52
type TestCase ¶ added in v1.0.52
type TestCase struct {
Description string `toml:"description"`
Eval []string `toml:"eval"`
Format string `toml:"format"`
Expected string `toml:"expected,omitempty"`
Files map[string]string `toml:"files"`
Errors []string `toml:"errors,omitempty"`
RootPath string `toml:"rootPath,omitempty"`
Env map[string]string `toml:"env,omitempty"`
Diff bool `toml:"diff,omitempty"`
Intersect bool `toml:"intersect,omitempty"`
Required bool `toml:"required,omitempty"`
Compare bool `toml:"compare,omitempty"`
Benchmark bool `toml:"benchmark,omitempty"`
Selector string `toml:"selector,omitempty"`
SortPath string `toml:"sortPath,omitempty"`
}