output

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Nov 29, 2025 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func WriteDifferencesReport

func WriteDifferencesReport(report *models.SyncReport, filepath string, format string) error

WriteDifferencesReport writes the differences report to a file or stdout If filepath is empty, writes to stdout Format can be "human" or "json"

Types

type Formatter

type Formatter interface {
	// Start initializes the formatter for a new sync operation
	// maxWorkers indicates the number of parallel workers for display purposes
	Start(writer io.Writer, totalFiles int, totalBytes int64, maxWorkers int) error

	// Progress reports progress during sync
	Progress(update ProgressUpdate) error

	// Complete finalizes output and displays summary
	Complete(report *models.SyncReport) error

	// Error reports an error during sync
	Error(err error) error

	// Name returns the formatter name
	Name() string
}

Formatter defines the interface for output formatting Implementations include human-readable and JSON formatters

type HumanFormatter

type HumanFormatter struct {
	// contains filtered or unexported fields
}

HumanFormatter formats output in human-readable format

func NewHumanFormatter

func NewHumanFormatter() *HumanFormatter

NewHumanFormatter creates a new human-readable formatter

func (*HumanFormatter) Complete

func (f *HumanFormatter) Complete(report *models.SyncReport) error

Complete finalizes output and displays summary

func (*HumanFormatter) Error

func (f *HumanFormatter) Error(err error) error

Error reports an error

func (*HumanFormatter) Name

func (f *HumanFormatter) Name() string

Name returns the formatter name

func (*HumanFormatter) Progress

func (f *HumanFormatter) Progress(update ProgressUpdate) error

Progress reports progress during sync

func (*HumanFormatter) Start

func (f *HumanFormatter) Start(writer io.Writer, totalFiles int, totalBytes int64, maxWorkers int) error

Start initializes the formatter

type JSONDifferenceData added in v0.3.0

type JSONDifferenceData struct {
	Path       string            `json:"path"`
	Reason     string            `json:"reason"`
	Details    string            `json:"details,omitempty"`
	SourceInfo *JSONFileInfoData `json:"source_info,omitempty"`
	DestInfo   *JSONFileInfoData `json:"dest_info,omitempty"`
}

JSONDifferenceData represents a file difference

type JSONErrorData added in v0.3.0

type JSONErrorData struct {
	Path  string `json:"path"`
	Error string `json:"error"`
}

JSONErrorData represents an error entry

type JSONEvent added in v0.3.0

type JSONEvent struct {
	Timestamp time.Time `json:"timestamp"`
	Type      string    `json:"type"`
	Data      any       `json:"data,omitempty"`
}

JSONEvent represents a single event in the JSON output stream

type JSONFileData added in v0.3.0

type JSONFileData struct {
	Path         string `json:"path"`
	BytesWritten int64  `json:"bytes_written,omitempty"`
	TotalBytes   int64  `json:"total_bytes,omitempty"`
	Error        string `json:"error,omitempty"`
}

JSONFileData represents file-related event data

type JSONFileInfoData added in v0.3.0

type JSONFileInfoData struct {
	Size    int64  `json:"size"`
	ModTime string `json:"mod_time"`
	Hash    string `json:"hash,omitempty"`
}

JSONFileInfoData represents file info in JSON

type JSONFormatter added in v0.3.0

type JSONFormatter struct {
	// contains filtered or unexported fields
}

JSONFormatter formats output as JSON for automation and scripting

func NewJSONFormatter added in v0.3.0

func NewJSONFormatter() *JSONFormatter

NewJSONFormatter creates a new JSON formatter

func (*JSONFormatter) Complete added in v0.3.0

func (f *JSONFormatter) Complete(report *models.SyncReport) error

Complete finalizes output and displays summary as JSON

func (*JSONFormatter) Error added in v0.3.0

func (f *JSONFormatter) Error(err error) error

Error reports an error

func (*JSONFormatter) Name added in v0.3.0

func (f *JSONFormatter) Name() string

Name returns the formatter name

func (*JSONFormatter) Progress added in v0.3.0

func (f *JSONFormatter) Progress(update ProgressUpdate) error

Progress reports progress during sync

func (*JSONFormatter) Start added in v0.3.0

func (f *JSONFormatter) Start(writer io.Writer, totalFiles int, totalBytes int64, maxWorkers int) error

Start initializes the formatter

type JSONOperationsData added in v0.3.0

type JSONOperationsData struct {
	FilesCopied       int32 `json:"files_copied"`
	FilesUpdated      int32 `json:"files_updated"`
	FilesDeleted      int32 `json:"files_deleted"`
	FilesSynchronized int32 `json:"files_synchronized"`
	FilesSkipped      int32 `json:"files_skipped"`
	FilesErrored      int32 `json:"files_errored"`
	DirsCreated       int32 `json:"dirs_created"`
	DirsDeleted       int32 `json:"dirs_deleted"`
}

JSONOperationsData represents operations statistics

type JSONReportData added in v0.3.0

type JSONReportData struct {
	Status      string               `json:"status"`
	Duration    string               `json:"duration"`
	DurationMs  int64                `json:"duration_ms"`
	Stats       JSONStatsData        `json:"stats"`
	Differences []JSONDifferenceData `json:"differences,omitempty"`
	Errors      []JSONErrorData      `json:"errors,omitempty"`
}

JSONReportData represents the final report data

type JSONScannedData added in v0.3.0

type JSONScannedData struct {
	SourceFiles int32 `json:"source_files"`
	SourceDirs  int32 `json:"source_dirs"`
	DestFiles   int32 `json:"dest_files"`
	DestDirs    int32 `json:"dest_dirs"`
	UniqueFiles int32 `json:"unique_files"`
	UniqueDirs  int32 `json:"unique_dirs"`
}

JSONScannedData represents scanned files statistics

type JSONStartData added in v0.3.0

type JSONStartData struct {
	TotalFiles int   `json:"total_files"`
	TotalBytes int64 `json:"total_bytes"`
}

JSONStartData represents the data for a start event

type JSONStatsData added in v0.3.0

type JSONStatsData struct {
	Scanned    JSONScannedData    `json:"scanned"`
	Operations JSONOperationsData `json:"operations"`
	Transfer   JSONTransferData   `json:"transfer"`
}

JSONStatsData represents statistics in JSON format

type JSONTransferData added in v0.3.0

type JSONTransferData struct {
	BytesTransferred int64  `json:"bytes_transferred"`
	AverageSpeed     int64  `json:"average_speed_bytes_per_sec,omitempty"`
	AverageSpeedStr  string `json:"average_speed,omitempty"`
}

JSONTransferData represents transfer statistics

type ProgressFormatter

type ProgressFormatter struct {
	// contains filtered or unexported fields
}

ProgressFormatter formats output with progress bars

func NewProgressFormatter

func NewProgressFormatter() *ProgressFormatter

NewProgressFormatter creates a new progress bar formatter

func (*ProgressFormatter) Complete

func (f *ProgressFormatter) Complete(report *models.SyncReport) error

Complete finalizes output and displays summary

func (*ProgressFormatter) Error

func (f *ProgressFormatter) Error(err error) error

Error reports an error

func (*ProgressFormatter) Name

func (f *ProgressFormatter) Name() string

Name returns the formatter name

func (*ProgressFormatter) Progress

func (f *ProgressFormatter) Progress(update ProgressUpdate) error

Progress reports progress during sync

func (*ProgressFormatter) Start

func (f *ProgressFormatter) Start(writer io.Writer, totalFiles int, totalBytes int64, maxWorkers int) error

Start initializes the formatter

type ProgressUpdate

type ProgressUpdate struct {
	Type         string // "file_start", "compare_start", "file_progress", "file_complete", "file_error", "summary"
	FilePath     string
	BytesWritten int64
	TotalBytes   int64
	CurrentFile  int
	TotalFiles   int
	Error        error
}

ProgressUpdate represents a progress notification during sync

Jump to

Keyboard shortcuts

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