Documentation
¶
Overview ¶
Package output provides formatting and output capabilities for duplicate file scan results.
This package implements a pluggable formatter system that supports multiple output formats:
- Pretty: Human-readable formatted output with colors and alignment
- JSON: Structured JSON output for programmatic consumption
- YAML: YAML format for configuration-style output
The package uses a registry pattern to manage formatters and provides utilities for formatting file sizes and other display elements.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func FormatBytes ¶
FormatBytes converts a byte count to a human-readable string.
Types ¶
type FormatterRegistry ¶
type FormatterRegistry struct {
// contains filtered or unexported fields
}
FormatterRegistry manages available output formatters.
func InitFormatters ¶
func InitFormatters() (*FormatterRegistry, error)
InitFormatters initializes the default output formatters and returns a registry.
func NewFormatterRegistry ¶
func NewFormatterRegistry() *FormatterRegistry
NewFormatterRegistry creates a new OutputFormatterRegistry.
func (*FormatterRegistry) Format ¶
func (r *FormatterRegistry) Format(name string, report *model.DuplicateReport, w io.Writer) error
Format formats the duplicate report using the specified formatter and writes it to the provided writer.
func (*FormatterRegistry) Get ¶
func (r *FormatterRegistry) Get(name string) (Formatter, bool)
Get retrieves a formatter by name from the registry.
func (*FormatterRegistry) List ¶
func (r *FormatterRegistry) List() []string
List returns a list of registered formatter names.
type JSONFormatter ¶
type JSONFormatter struct{}
JSONFormatter formats duplicate reports as JSON.
func NewJSONFormatter ¶
func NewJSONFormatter() *JSONFormatter
NewJSONFormatter creates a new JSON formatter.
func (*JSONFormatter) Format ¶
func (f *JSONFormatter) Format(report *model.DuplicateReport, w io.Writer) error
Format writes the duplicate report as formatted JSON to the writer.
func (*JSONFormatter) Name ¶
func (f *JSONFormatter) Name() string
Name returns the name of the formatter.
type PrettyFormatter ¶
type PrettyFormatter struct{}
PrettyFormatter formats duplicate reports in a human-readable way.
func NewPrettyFormatter ¶
func NewPrettyFormatter() *PrettyFormatter
NewPrettyFormatter creates a new PrettyFormatter instance.
func (*PrettyFormatter) Format ¶
func (f *PrettyFormatter) Format(report *model.DuplicateReport, w io.Writer) error
Format formats the duplicate report in a human-readable way and writes it to the provided writer. Inspired by the Catppuccin theme.
func (*PrettyFormatter) Name ¶
func (f *PrettyFormatter) Name() string
Name returns the name of the formatter.
type YAMLFormatter ¶
type YAMLFormatter struct{}
YAMLFormatter formats duplicate reports as YAML.
func NewYAMLFormatter ¶
func NewYAMLFormatter() *YAMLFormatter
NewYAMLFormatter creates a new YAML formatter.
func (*YAMLFormatter) Format ¶
func (f *YAMLFormatter) Format(report *model.DuplicateReport, w io.Writer) error
Format writes the duplicate report as formatted YAML to the writer.
func (*YAMLFormatter) Name ¶
func (f *YAMLFormatter) Name() string
Name returns the name of the formatter.