configfile

package
v3.0.0-rc.1 Latest Latest
Warning

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

Go to latest
Published: Jul 16, 2026 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const FileName = ".cfv.toml"

Variables

This section is empty.

Functions

func Discover

func Discover(startDir string) string

Discover walks up from startDir looking for a .cfv.toml file. Returns the path if found, or empty string if not found.

Types

type CSVOptions

type CSVOptions struct {
	Delimiter  *string `toml:"delimiter"`
	Comment    *string `toml:"comment"`
	LazyQuotes *bool   `toml:"lazy-quotes"`
}

CSVOptions configures the CSV validator.

type Config

type Config struct {
	ExcludeDirs      []string          `toml:"exclude-dirs"`
	ExcludeFileTypes []string          `toml:"exclude-file-types"`
	IgnoreFiles      []string          `toml:"ignore-files"`
	FileTypes        []string          `toml:"file-types"`
	Depth            *int              `toml:"depth"`
	Reporter         []string          `toml:"reporter"`
	GroupBy          []string          `toml:"groupby"`
	Quiet            *bool             `toml:"quiet"`
	RequireSchema    *bool             `toml:"require-schema"`
	NoSchema         *bool             `toml:"no-schema"`
	SchemaStore      *bool             `toml:"schemastore"`
	SchemaStorePath  *string           `toml:"schemastore-path"`
	Globbing         *bool             `toml:"globbing"`
	Gitignore        *bool             `toml:"gitignore"`
	Editorconfig     *bool             `toml:"editorconfig"`
	SchemaMap        map[string]string `toml:"schema-map"`
	TypeMap          map[string]string `toml:"type-map"`
	Validators       ValidatorOptions  `toml:"validators"`
	Format           FormatConfig      `toml:"format"`
}

Config represents the parsed .cfv.toml configuration file.

func Load

func Load(path string) (*Config, error)

Load reads and validates a .cfv.toml file at the given path. It validates TOML syntax first, then validates against the embedded schema.

type FormatConfig

type FormatConfig struct {
	FormatOptions

	// Per-format overrides. Keys are format names: "json", "yaml", "hcl", etc.
	JSON       *FormatOptions `toml:"json"`
	JSONC      *FormatOptions `toml:"jsonc"`
	YAML       *FormatOptions `toml:"yaml"`
	HCL        *FormatOptions `toml:"hcl"`
	TOML       *FormatOptions `toml:"toml"`
	XML        *FormatOptions `toml:"xml"`
	INI        *FormatOptions `toml:"ini"`
	ENV        *FormatOptions `toml:"env"`
	Properties *FormatOptions `toml:"properties"`
}

FormatConfig holds the [format] section and per-format overrides.

type FormatOptions

type FormatOptions struct {
	Indent          *int    `toml:"indent"`
	UseTabs         *bool   `toml:"use-tabs"`
	SortKeys        *bool   `toml:"sort-keys"`
	TrailingNewline *bool   `toml:"trailing-newline"`
	LineEnding      *string `toml:"line-ending"`
	MaxLineWidth    *int    `toml:"max-line-width"`
	QuoteStyle      *string `toml:"quote-style"`
}

FormatOptions holds formatting configuration keys. All fields are pointers so we can distinguish "not set" from "set to zero/false". This allows correct cascade resolution: CLI > per-format > global > defaults.

type INIOptions

type INIOptions struct {
	ForbidDuplicateKeys *bool `toml:"forbid-duplicate-keys"`
}

INIOptions configures the INI validator.

type JSONOptions

type JSONOptions struct {
	ForbidDuplicateKeys *bool `toml:"forbid-duplicate-keys"`
}

JSONOptions configures the JSON validator.

type ValidatorOptions

type ValidatorOptions struct {
	CSV  *CSVOptions  `toml:"csv"`
	JSON *JSONOptions `toml:"json"`
	INI  *INIOptions  `toml:"ini"`
}

ValidatorOptions holds per-validator configuration.

Jump to

Keyboard shortcuts

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