Documentation
¶
Index ¶
- func GroupByDirectory(reports []reporter.Report) map[string][]reporter.Report
- func GroupByErrorType(reports []reporter.Report) map[string][]reporter.Report
- func GroupByFileType(reports []reporter.Report) map[string][]reporter.Report
- func GroupByPassFail(reports []reporter.Report) map[string][]reporter.Report
- type CLI
- type File
- type FileSystem
- type FormatOptionsFunc
- type GroupNode
- type Option
- func WithDiff(diff bool) Option
- func WithFinder(f finder.FileFinder) Option
- func WithFix(fix bool) Option
- func WithGroupOutput(groupOutput []string) Option
- func WithNoSchema(noSchema bool) Option
- func WithQuiet(quiet bool) Option
- func WithReporters(r ...reporter.Reporter) Option
- func WithRequireSchema(require bool) Option
- func WithSchemaMap(m map[string]string) Option
- func WithSchemaStore(s *schemastore.Store) Option
- func WithStdinData(data []byte, ft filetype.FileType) Option
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GroupByDirectory ¶
GroupByDirectory groups reports by containing directory.
func GroupByErrorType ¶
GroupByErrorType groups reports by error type.
func GroupByFileType ¶
GroupByFileType groups reports by file extension.
Types ¶
type CLI ¶
type CLI struct {
// contains filtered or unexported fields
}
CLI is the main entry point for running config file validation and formatting. Use Init with Option functions to configure, then call Run (check) or Format.
func (*CLI) Format ¶
func (c *CLI) Format(optsFunc FormatOptionsFunc) (int, error)
Format runs the formatting pipeline.
For each discovered file whose FileType has a registered Formatter:
- If the file is already formatted: Report{Status: StatusPass}
- If the file needs formatting: Report{Status: StatusUnformatted}
- If --fix is set: rewrite the file atomically, report as StatusPass
- If the file cannot be parsed by the formatter: skipped (not reported)
- If the file cannot be read (non-symlink): skipped (not reported)
Files whose FileType has no Formatter are silently skipped. Broken symlinks are reported as StatusFail.
Returns 0 if all files are formatted (or all were fixed), 1 if any file needs formatting and --fix was not set, 2 on tool error.
type FileSystem ¶
type FileSystem interface {
Stat(path string) (fs.FileInfo, error)
CreateTemp(dir, pattern string) (File, error)
Chmod(path string, mode fs.FileMode) error
Rename(oldpath, newpath string) error
Remove(path string) error
}
FileSystem abstracts file operations for testability.
type FormatOptionsFunc ¶
FormatOptionsFunc returns resolved format options for a given format name.
type Option ¶
type Option func(*CLI)
Option configures a CLI instance.
func WithDiff ¶
WithDiff enables unified diff output mode for Format. When true, Format prints diffs instead of the normal pass/fail report.
func WithFinder ¶
func WithFinder(f finder.FileFinder) Option
func WithFix ¶
WithFix enables writing formatted output back to disk when calling Format. When false (the default), Format reports issues but does not modify files.
func WithGroupOutput ¶
func WithNoSchema ¶
func WithReporters ¶
func WithRequireSchema ¶
func WithSchemaMap ¶
func WithSchemaStore ¶
func WithSchemaStore(s *schemastore.Store) Option