output

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Oct 10, 2025 License: MIT Imports: 9 Imported by: 0

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

func FormatBytes(bytes int64) string

FormatBytes converts a byte count to a human-readable string.

Types

type Formatter

type Formatter interface {
	Name() string
	Format(report *model.DuplicateReport, w io.Writer) error
}

Formatter formats duplicate reports to different output formats.

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.

func (*FormatterRegistry) Register

func (r *FormatterRegistry) Register(name string, formatter Formatter) error

Register adds a new formatter to the registry.

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.

Jump to

Keyboard shortcuts

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