Documentation
¶
Overview ¶
Package reporter provides a progress reporting interface with text, JSON Lines, and no-op implementations.
Index ¶
- type EventType
- type JSONReporter
- func (r *JSONReporter) Complete(message string, details any)
- func (r *JSONReporter) Error(err error, message string)
- func (r *JSONReporter) IsJSON() bool
- func (r *JSONReporter) Message(format string, args ...any)
- func (r *JSONReporter) MessagePlain(format string, args ...any)
- func (r *JSONReporter) Progress(percent int, message string)
- func (r *JSONReporter) Step(step, total int, name string)
- func (r *JSONReporter) Warning(format string, args ...any)
- type NoopReporter
- func (NoopReporter) Complete(string, any)
- func (NoopReporter) Error(error, string)
- func (NoopReporter) IsJSON() bool
- func (NoopReporter) Message(string, ...any)
- func (NoopReporter) MessagePlain(string, ...any)
- func (NoopReporter) Progress(int, string)
- func (NoopReporter) Step(int, int, string)
- func (NoopReporter) Warning(string, ...any)
- type ProgressEvent
- type Reporter
- type TextReporter
- func (r *TextReporter) Complete(message string, _ any)
- func (r *TextReporter) Error(err error, message string)
- func (r *TextReporter) IsJSON() bool
- func (r *TextReporter) Message(format string, args ...any)
- func (r *TextReporter) MessagePlain(format string, args ...any)
- func (r *TextReporter) Progress(_ int, message string)
- func (r *TextReporter) Step(step, total int, name string)
- func (r *TextReporter) Warning(format string, args ...any)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type JSONReporter ¶
type JSONReporter struct {
// contains filtered or unexported fields
}
JSONReporter writes JSON Lines (one ProgressEvent per line) to an io.Writer. All writes are serialized with a mutex for thread safety.
func NewJSONReporter ¶
func NewJSONReporter(w io.Writer) *JSONReporter
NewJSONReporter returns a JSONReporter that writes to w.
func (*JSONReporter) Complete ¶
func (r *JSONReporter) Complete(message string, details any)
func (*JSONReporter) Error ¶
func (r *JSONReporter) Error(err error, message string)
func (*JSONReporter) IsJSON ¶
func (r *JSONReporter) IsJSON() bool
func (*JSONReporter) Message ¶
func (r *JSONReporter) Message(format string, args ...any)
func (*JSONReporter) MessagePlain ¶
func (r *JSONReporter) MessagePlain(format string, args ...any)
func (*JSONReporter) Progress ¶
func (r *JSONReporter) Progress(percent int, message string)
func (*JSONReporter) Step ¶
func (r *JSONReporter) Step(step, total int, name string)
func (*JSONReporter) Warning ¶
func (r *JSONReporter) Warning(format string, args ...any)
type NoopReporter ¶
type NoopReporter struct{}
NoopReporter silently discards all output. Useful for tests and contexts where no progress reporting is needed.
func (NoopReporter) Complete ¶
func (NoopReporter) Complete(string, any)
func (NoopReporter) Error ¶
func (NoopReporter) Error(error, string)
func (NoopReporter) IsJSON ¶
func (NoopReporter) IsJSON() bool
func (NoopReporter) Message ¶
func (NoopReporter) Message(string, ...any)
func (NoopReporter) MessagePlain ¶
func (NoopReporter) MessagePlain(string, ...any)
func (NoopReporter) Progress ¶
func (NoopReporter) Progress(int, string)
func (NoopReporter) Warning ¶
func (NoopReporter) Warning(string, ...any)
type ProgressEvent ¶
type ProgressEvent struct {
Type EventType `json:"type"`
Timestamp string `json:"timestamp"`
Step int `json:"step,omitzero"`
TotalSteps int `json:"total_steps,omitzero"`
StepName string `json:"step_name,omitempty"`
Message string `json:"message,omitempty"`
Percent int `json:"percent,omitzero"`
Details any `json:"details,omitempty"`
}
ProgressEvent represents a single line of JSON Lines output for streaming progress.
type Reporter ¶
type Reporter interface {
Step(step, total int, name string)
Progress(percent int, message string)
Message(format string, args ...any)
MessagePlain(format string, args ...any)
Warning(format string, args ...any)
Error(err error, message string)
Complete(message string, details any)
IsJSON() bool
}
Reporter is the interface for reporting progress and messages. It has three implementations:
- TextReporter: human-readable text output
- JSONReporter: machine-readable JSON Lines output
- NoopReporter: silently discards all output
type TextReporter ¶
type TextReporter struct {
// contains filtered or unexported fields
}
TextReporter writes human-readable progress text to an io.Writer.
func NewTextReporter ¶
func NewTextReporter(w io.Writer) *TextReporter
NewTextReporter returns a TextReporter that writes to w.
func (*TextReporter) Complete ¶
func (r *TextReporter) Complete(message string, _ any)
func (*TextReporter) Error ¶
func (r *TextReporter) Error(err error, message string)
func (*TextReporter) IsJSON ¶
func (r *TextReporter) IsJSON() bool
func (*TextReporter) Message ¶
func (r *TextReporter) Message(format string, args ...any)
func (*TextReporter) MessagePlain ¶
func (r *TextReporter) MessagePlain(format string, args ...any)
func (*TextReporter) Progress ¶
func (r *TextReporter) Progress(_ int, message string)
func (*TextReporter) Step ¶
func (r *TextReporter) Step(step, total int, name string)
func (*TextReporter) Warning ¶
func (r *TextReporter) Warning(format string, args ...any)