Documentation
¶
Overview ¶
Package output provides build output formatting and reporting.
This package implements various output reporters for displaying build progress and results to users. The primary reporter is NormalReporter which outputs:
- Target being built
- Command output (stdout/stderr)
- Completion/failure status
Example usage:
reporter := output.NewNormalReporter(os.Stdout)
reporter.BuildStarted("build/app")
reporter.CommandOutput("gcc -c main.c", "", "")
reporter.BuildCompleted("build/app", true, "")
reporter.Summary(1, 0)
Index ¶
- func Bold(text string, enabled bool) string
- func Colorize(text string, color Color, enabled bool) string
- func ColorizeStatus(text string, success bool, enabled bool) string
- func DefaultTerminalSize() (width, height int)
- func DetectUnicodeSupport() bool
- func Dim(text string, enabled bool) string
- func GetTerminalSize() (width, height int)
- func ShouldUseColor(colorSetting string) bool
- func ShouldUseUnicode(unicodeSetting string) bool
- type BuildSummary
- type CLIWriter
- type Color
- type ColorConfig
- type ColorLevel
- type CommandCompleted
- type CommandOutput
- type CommandStarted
- type DryRunCommand
- type DryRunReporter
- type DryRunTarget
- type Emitter
- func (e *Emitter) BuildSummary(total, succeeded, failed, skipped int, duration time.Duration)
- func (e *Emitter) CommandCompleted(target, command string, exitCode int, duration time.Duration)
- func (e *Emitter) CommandOutput(target, stdout, stderr string)
- func (e *Emitter) CommandStarted(target, command string)
- func (e *Emitter) DryRunCommand(target, command string)
- func (e *Emitter) DryRunTarget(target string, index, total int)
- func (e *Emitter) Error(category, code, message, location, context, hint string)
- func (e *Emitter) Flush()
- func (e *Emitter) PhaseCompleted(phase string, duration time.Duration)
- func (e *Emitter) PhaseStarted(phase string)
- func (e *Emitter) StalenessChecked(target, reason, action string)
- func (e *Emitter) TargetCompleted(target string, success bool, duration time.Duration, errMsg string)
- func (e *Emitter) TargetSkipped(target, reason string)
- func (e *Emitter) TargetStarted(target string, index, total int)
- func (e *Emitter) VariableEvaluated(name, expr, result string)
- type EmitterBackedDryRunReporter
- func (r *EmitterBackedDryRunReporter) NothingToBuild(target string)
- func (r *EmitterBackedDryRunReporter) SetTotal(total int)
- func (r *EmitterBackedDryRunReporter) ShowCommand(command string)
- func (r *EmitterBackedDryRunReporter) Summary(total int)
- func (r *EmitterBackedDryRunReporter) TargetComplete()
- func (r *EmitterBackedDryRunReporter) WouldBuild(target string)
- type EmitterBackedNormalReporter
- func (r *EmitterBackedNormalReporter) BuildCompleted(target string, success bool, errMsg string)
- func (r *EmitterBackedNormalReporter) BuildStarted(target string)
- func (r *EmitterBackedNormalReporter) CommandOutput(command, stdout, stderr string)
- func (r *EmitterBackedNormalReporter) CommandStarted(target, command string)
- func (r *EmitterBackedNormalReporter) NothingToBuild(target string)
- func (r *EmitterBackedNormalReporter) SetTotal(total int)
- func (r *EmitterBackedNormalReporter) Summary(total, failed int)
- type EmitterBackedProgressReporter
- func (r *EmitterBackedProgressReporter) BuildCompleted(target string, success bool, errMsg string)
- func (r *EmitterBackedProgressReporter) BuildStarted(target string)
- func (r *EmitterBackedProgressReporter) CommandOutput(command, stdout, stderr string)
- func (r *EmitterBackedProgressReporter) CurrentlyBuilding() []string
- func (r *EmitterBackedProgressReporter) NothingToBuild(target string)
- func (r *EmitterBackedProgressReporter) Summary(total, failed int)
- type EmitterBackedVerboseReporter
- func (r *EmitterBackedVerboseReporter) BuildCompleted(target string, success bool, errMsg string)
- func (r *EmitterBackedVerboseReporter) BuildStarted(target string)
- func (r *EmitterBackedVerboseReporter) CommandExecuted(command string)
- func (r *EmitterBackedVerboseReporter) CommandOutput(command, stdout, stderr string)
- func (r *EmitterBackedVerboseReporter) NothingToBuild(target string)
- func (r *EmitterBackedVerboseReporter) SetTotal(total int)
- func (r *EmitterBackedVerboseReporter) StalenessCheck(target, reason, action string)
- func (r *EmitterBackedVerboseReporter) StartStalenessChecks()
- func (r *EmitterBackedVerboseReporter) StartVariableEvaluation()
- func (r *EmitterBackedVerboseReporter) Summary(total, failed int)
- func (r *EmitterBackedVerboseReporter) VariableEvaluated(name, expr, result string)
- type ErrorOccurred
- type HeadlessWriter
- type NormalReporter
- func (r *NormalReporter) BuildCompleted(target string, success bool, errMsg string)
- func (r *NormalReporter) BuildStarted(target string)
- func (r *NormalReporter) CommandOutput(command, stdout, stderr string)
- func (r *NormalReporter) NothingToBuild(target string)
- func (r *NormalReporter) Summary(total, failed int)
- type OutputEvent
- type OutputMode
- type OutputWriter
- type PhaseCompleted
- type PhaseStarted
- type ProgressReporter
- func (r *ProgressReporter) BuildCompleted(target string, success bool, errMsg string)
- func (r *ProgressReporter) BuildStarted(target string)
- func (r *ProgressReporter) CommandOutput(command, stdout, stderr string)
- func (r *ProgressReporter) CurrentlyBuilding() []string
- func (r *ProgressReporter) NothingToBuild(target string)
- func (r *ProgressReporter) Summary(total, failed int)
- type Reporter
- type StalenessChecked
- type TUIWriter
- type TargetCompleted
- type TargetSkipped
- type TargetStarted
- type TerminalCapabilities
- type VariableEvaluated
- type VerboseReporter
- func (r *VerboseReporter) BuildCompleted(target string, success bool, errMsg string)
- func (r *VerboseReporter) BuildStarted(target string)
- func (r *VerboseReporter) CommandExecuted(command string)
- func (r *VerboseReporter) CommandOutput(command, stdout, stderr string)
- func (r *VerboseReporter) NothingToBuild(target string)
- func (r *VerboseReporter) StalenessCheck(target, reason, action string)
- func (r *VerboseReporter) StartStalenessChecks()
- func (r *VerboseReporter) StartVariableEvaluation()
- func (r *VerboseReporter) Summary(total, failed int)
- func (r *VerboseReporter) VariableEvaluated(name, expr, result string)
- type WriterConfig
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ColorizeStatus ¶
ColorizeStatus colors text based on success/failure.
func DefaultTerminalSize ¶
func DefaultTerminalSize() (width, height int)
DefaultTerminalSize returns the default terminal dimensions.
func DetectUnicodeSupport ¶
func DetectUnicodeSupport() bool
DetectUnicodeSupport detects if the terminal supports Unicode.
func GetTerminalSize ¶
func GetTerminalSize() (width, height int)
GetTerminalSize returns the current terminal dimensions. Returns (0, 0) if detection fails or stdout is not a terminal.
func ShouldUseColor ¶
ShouldUseColor determines if colors should be used based on config.
func ShouldUseUnicode ¶
ShouldUseUnicode determines if Unicode should be used based on config.
Types ¶
type BuildSummary ¶
type BuildSummary struct {
Total int // Total number of targets
Succeeded int // Number that succeeded
Failed int // Number that failed
Skipped int // Number that were skipped
Duration time.Duration // Total build duration
}
BuildSummary is emitted at the end of a build.
type CLIWriter ¶
type CLIWriter struct {
// contains filtered or unexported fields
}
CLIWriter implements OutputWriter for interactive terminal output. It provides colored output, progress indicators, and formatted messages.
func NewCLIWriter ¶
func NewCLIWriter(w io.Writer, config WriterConfig) *CLIWriter
NewCLIWriter creates a new CLIWriter that writes to w.
func (*CLIWriter) WriteEvent ¶
func (c *CLIWriter) WriteEvent(event OutputEvent)
WriteEvent renders an output event to the terminal.
type Color ¶
type Color string
Color represents an ANSI color code.
const ( ColorReset Color = "\033[0m" ColorBold Color = "\033[1m" ColorDim Color = "\033[2m" ColorRed Color = "\033[31m" ColorGreen Color = "\033[32m" ColorYellow Color = "\033[33m" ColorBlue Color = "\033[34m" ColorMagenta Color = "\033[35m" ColorCyan Color = "\033[36m" ColorWhite Color = "\033[37m" ColorGray Color = "\033[90m" // Bold variants ColorBoldRed Color = "\033[1;31m" ColorBoldGreen Color = "\033[1;32m" ColorBoldCyan Color = "\033[1;36m" )
ANSI color codes for terminal output.
type ColorConfig ¶
type ColorConfig struct {
Enabled bool
}
ColorConfig determines how colors are applied.
type ColorLevel ¶
type ColorLevel int
ColorLevel represents the level of color support.
const ( // ColorLevelNone indicates no color support. ColorLevelNone ColorLevel = iota // ColorLevelBasic indicates 16-color support (standard ANSI). ColorLevelBasic // ColorLevel256 indicates 256-color support. ColorLevel256 // ColorLevelTruecolor indicates 24-bit truecolor support. ColorLevelTruecolor )
func DetectColorLevel ¶
func DetectColorLevel() ColorLevel
DetectColorLevel detects the color level supported by the terminal.
func (ColorLevel) String ¶
func (c ColorLevel) String() string
String returns a human-readable name for the color level.
type CommandCompleted ¶
type CommandCompleted struct {
Target string // Target being built
Command string // Command that was executed
ExitCode int // Exit code (0 = success)
Duration time.Duration // How long the command took
}
CommandCompleted is emitted when a command finishes execution.
type CommandOutput ¶
type CommandOutput struct {
Target string // Target being built
Stdout string // Standard output
Stderr string // Standard error
}
CommandOutput is emitted when a command produces output.
type CommandStarted ¶
type CommandStarted struct {
Target string // Target being built
Command string // Command line being executed
}
CommandStarted is emitted when a recipe command begins execution.
type DryRunCommand ¶
type DryRunCommand struct {
Target string // Target this command belongs to
Command string // Command that would be executed
}
DryRunCommand is emitted in dry-run mode to show commands that would run.
type DryRunReporter ¶
type DryRunReporter struct {
// contains filtered or unexported fields
}
DryRunReporter implements output formatting for dry-run mode. It shows "Would build: target" followed by indented commands.
func NewDryRunReporter ¶
func NewDryRunReporter(w io.Writer) *DryRunReporter
NewDryRunReporter creates a new DryRunReporter that writes to w.
func (*DryRunReporter) NothingToBuild ¶
func (r *DryRunReporter) NothingToBuild(target string)
NothingToBuild outputs that a target is already up to date.
func (*DryRunReporter) ShowCommand ¶
func (r *DryRunReporter) ShowCommand(command string)
ShowCommand outputs a command that would be executed (indented).
func (*DryRunReporter) Summary ¶
func (r *DryRunReporter) Summary(total int)
Summary outputs a summary of what would be built.
func (*DryRunReporter) TargetComplete ¶
func (r *DryRunReporter) TargetComplete()
TargetComplete marks the end of a target's commands. Adds a blank line between targets for readability.
func (*DryRunReporter) WouldBuild ¶
func (r *DryRunReporter) WouldBuild(target string)
WouldBuild outputs "Would build: target" line.
type DryRunTarget ¶
type DryRunTarget struct {
Target string // Target that would be built
Index int // 1-based index
Total int // Total targets
}
DryRunTarget is emitted in dry-run mode to show what would be built.
type Emitter ¶
type Emitter struct {
// contains filtered or unexported fields
}
Emitter provides a convenient API for emitting output events. It wraps an OutputWriter and provides typed methods for each event type.
func NewEmitter ¶
func NewEmitter(writer OutputWriter) *Emitter
NewEmitter creates a new Emitter that writes events to the given writer. If writer is nil, events are silently discarded.
func NoOpEmitter ¶
func NoOpEmitter() *Emitter
NoOpEmitter returns an emitter that discards all events.
func (*Emitter) BuildSummary ¶
BuildSummary emits a build summary event.
func (*Emitter) CommandCompleted ¶
CommandCompleted emits a command completion event.
func (*Emitter) CommandOutput ¶
CommandOutput emits a command output event.
func (*Emitter) CommandStarted ¶
CommandStarted emits a command start event.
func (*Emitter) DryRunCommand ¶
DryRunCommand emits a dry-run command event.
func (*Emitter) DryRunTarget ¶
DryRunTarget emits a dry-run target event.
func (*Emitter) PhaseCompleted ¶
PhaseCompleted emits a phase completion event.
func (*Emitter) PhaseStarted ¶
PhaseStarted emits a phase start event.
func (*Emitter) StalenessChecked ¶
StalenessChecked emits a staleness check event.
func (*Emitter) TargetCompleted ¶
func (e *Emitter) TargetCompleted(target string, success bool, duration time.Duration, errMsg string)
TargetCompleted emits a target build completion event.
func (*Emitter) TargetSkipped ¶
TargetSkipped emits a target skipped event.
func (*Emitter) TargetStarted ¶
TargetStarted emits a target build start event.
func (*Emitter) VariableEvaluated ¶
VariableEvaluated emits a variable evaluation event. expr is the expression (empty for simple values), result is the evaluated value.
type EmitterBackedDryRunReporter ¶
type EmitterBackedDryRunReporter struct {
// contains filtered or unexported fields
}
EmitterBackedDryRunReporter implements dry-run output using the emitter system.
func NewEmitterBackedDryRunReporter ¶
func NewEmitterBackedDryRunReporter(w io.Writer, config WriterConfig) *EmitterBackedDryRunReporter
NewEmitterBackedDryRunReporter creates a dry-run reporter backed by emitter.
func (*EmitterBackedDryRunReporter) NothingToBuild ¶
func (r *EmitterBackedDryRunReporter) NothingToBuild(target string)
NothingToBuild outputs that a target is already up to date.
func (*EmitterBackedDryRunReporter) SetTotal ¶
func (r *EmitterBackedDryRunReporter) SetTotal(total int)
SetTotal sets the total number of targets for progress display.
func (*EmitterBackedDryRunReporter) ShowCommand ¶
func (r *EmitterBackedDryRunReporter) ShowCommand(command string)
ShowCommand outputs a command that would be executed.
func (*EmitterBackedDryRunReporter) Summary ¶
func (r *EmitterBackedDryRunReporter) Summary(total int)
Summary outputs a summary of what would be built.
func (*EmitterBackedDryRunReporter) TargetComplete ¶
func (r *EmitterBackedDryRunReporter) TargetComplete()
TargetComplete marks the end of a target's commands.
func (*EmitterBackedDryRunReporter) WouldBuild ¶
func (r *EmitterBackedDryRunReporter) WouldBuild(target string)
WouldBuild outputs "Would build: target" line.
type EmitterBackedNormalReporter ¶
type EmitterBackedNormalReporter struct {
// contains filtered or unexported fields
}
EmitterBackedNormalReporter implements the Reporter interface using the event-based OutputWriter system. This provides colored output and unified output handling across CLI, TUI, and headless modes.
func NewEmitterBackedNormalReporter ¶
func NewEmitterBackedNormalReporter(w io.Writer, config WriterConfig) *EmitterBackedNormalReporter
NewEmitterBackedNormalReporter creates a reporter backed by the emitter system.
func (*EmitterBackedNormalReporter) BuildCompleted ¶
func (r *EmitterBackedNormalReporter) BuildCompleted(target string, success bool, errMsg string)
BuildCompleted is called when a target build finishes.
func (*EmitterBackedNormalReporter) BuildStarted ¶
func (r *EmitterBackedNormalReporter) BuildStarted(target string)
BuildStarted is called when a target build begins.
func (*EmitterBackedNormalReporter) CommandOutput ¶
func (r *EmitterBackedNormalReporter) CommandOutput(command, stdout, stderr string)
CommandOutput is called to display command output.
func (*EmitterBackedNormalReporter) CommandStarted ¶
func (r *EmitterBackedNormalReporter) CommandStarted(target, command string)
CommandStarted is called before a command is executed.
func (*EmitterBackedNormalReporter) NothingToBuild ¶
func (r *EmitterBackedNormalReporter) NothingToBuild(target string)
NothingToBuild is called when a target is already up to date.
func (*EmitterBackedNormalReporter) SetTotal ¶
func (r *EmitterBackedNormalReporter) SetTotal(total int)
SetTotal sets the total number of targets for progress display.
func (*EmitterBackedNormalReporter) Summary ¶
func (r *EmitterBackedNormalReporter) Summary(total, failed int)
Summary is called at the end to show build summary.
type EmitterBackedProgressReporter ¶
type EmitterBackedProgressReporter struct {
// contains filtered or unexported fields
}
EmitterBackedProgressReporter implements progress output for parallel builds using the emitter system.
func NewEmitterBackedProgressReporter ¶
func NewEmitterBackedProgressReporter(w io.Writer, config WriterConfig, total int) *EmitterBackedProgressReporter
NewEmitterBackedProgressReporter creates a progress reporter backed by emitter.
func (*EmitterBackedProgressReporter) BuildCompleted ¶
func (r *EmitterBackedProgressReporter) BuildCompleted(target string, success bool, errMsg string)
BuildCompleted handles target build completion.
func (*EmitterBackedProgressReporter) BuildStarted ¶
func (r *EmitterBackedProgressReporter) BuildStarted(target string)
BuildStarted shows progress for a target starting to build.
func (*EmitterBackedProgressReporter) CommandOutput ¶
func (r *EmitterBackedProgressReporter) CommandOutput(command, stdout, stderr string)
CommandOutput outputs command stdout and stderr (for errors).
func (*EmitterBackedProgressReporter) CurrentlyBuilding ¶
func (r *EmitterBackedProgressReporter) CurrentlyBuilding() []string
CurrentlyBuilding returns the list of currently building targets.
func (*EmitterBackedProgressReporter) NothingToBuild ¶
func (r *EmitterBackedProgressReporter) NothingToBuild(target string)
NothingToBuild outputs that a target is already up to date.
func (*EmitterBackedProgressReporter) Summary ¶
func (r *EmitterBackedProgressReporter) Summary(total, failed int)
Summary outputs the build summary.
type EmitterBackedVerboseReporter ¶
type EmitterBackedVerboseReporter struct {
// contains filtered or unexported fields
}
EmitterBackedVerboseReporter implements verbose output using the emitter system.
func NewEmitterBackedVerboseReporter ¶
func NewEmitterBackedVerboseReporter(w io.Writer, config WriterConfig) *EmitterBackedVerboseReporter
NewEmitterBackedVerboseReporter creates a verbose reporter backed by emitter.
func (*EmitterBackedVerboseReporter) BuildCompleted ¶
func (r *EmitterBackedVerboseReporter) BuildCompleted(target string, success bool, errMsg string)
BuildCompleted outputs completion status for a target build.
func (*EmitterBackedVerboseReporter) BuildStarted ¶
func (r *EmitterBackedVerboseReporter) BuildStarted(target string)
BuildStarted outputs a header for building a target.
func (*EmitterBackedVerboseReporter) CommandExecuted ¶
func (r *EmitterBackedVerboseReporter) CommandExecuted(command string)
CommandExecuted outputs a command that was executed (indented).
func (*EmitterBackedVerboseReporter) CommandOutput ¶
func (r *EmitterBackedVerboseReporter) CommandOutput(command, stdout, stderr string)
CommandOutput outputs command stdout and stderr.
func (*EmitterBackedVerboseReporter) NothingToBuild ¶
func (r *EmitterBackedVerboseReporter) NothingToBuild(target string)
NothingToBuild outputs that a target is already up to date.
func (*EmitterBackedVerboseReporter) SetTotal ¶
func (r *EmitterBackedVerboseReporter) SetTotal(total int)
SetTotal sets the total number of targets for progress display.
func (*EmitterBackedVerboseReporter) StalenessCheck ¶
func (r *EmitterBackedVerboseReporter) StalenessCheck(target, reason, action string)
StalenessCheck outputs a staleness check result.
func (*EmitterBackedVerboseReporter) StartStalenessChecks ¶
func (r *EmitterBackedVerboseReporter) StartStalenessChecks()
StartStalenessChecks outputs a header for the staleness check phase.
func (*EmitterBackedVerboseReporter) StartVariableEvaluation ¶
func (r *EmitterBackedVerboseReporter) StartVariableEvaluation()
StartVariableEvaluation outputs a header for the variable evaluation phase.
func (*EmitterBackedVerboseReporter) Summary ¶
func (r *EmitterBackedVerboseReporter) Summary(total, failed int)
Summary outputs the build summary.
func (*EmitterBackedVerboseReporter) VariableEvaluated ¶
func (r *EmitterBackedVerboseReporter) VariableEvaluated(name, expr, result string)
VariableEvaluated outputs a variable evaluation result.
type ErrorOccurred ¶
type ErrorOccurred struct {
Category string // "parse", "semantic", "eval", "plan", "execute"
Code string // "E001", "E200", etc.
Message string // Error message
Location string // "Buildfile:10:5" or empty
Context string // Source code snippet or empty
Hint string // Fix suggestion or empty
}
ErrorOccurred is emitted when an error occurs during any phase.
type HeadlessWriter ¶
type HeadlessWriter struct {
// contains filtered or unexported fields
}
HeadlessWriter implements OutputWriter for CI/CD and log collection. It produces timestamped, plain-text output without ANSI codes.
func NewHeadlessWriter ¶
func NewHeadlessWriter(w io.Writer, config WriterConfig) *HeadlessWriter
NewHeadlessWriter creates a new HeadlessWriter.
func (*HeadlessWriter) Flush ¶
func (h *HeadlessWriter) Flush()
Flush ensures all output is written.
func (*HeadlessWriter) WriteEvent ¶
func (h *HeadlessWriter) WriteEvent(event OutputEvent)
WriteEvent renders an output event to the log stream.
type NormalReporter ¶
type NormalReporter struct {
// contains filtered or unexported fields
}
NormalReporter implements Reporter for normal (non-verbose) output. It shows target names being built, command output, and completion status.
func NewNormalReporter ¶
func NewNormalReporter(w io.Writer) *NormalReporter
NewNormalReporter creates a new NormalReporter that writes to w.
func (*NormalReporter) BuildCompleted ¶
func (r *NormalReporter) BuildCompleted(target string, success bool, errMsg string)
BuildCompleted outputs the build result.
func (*NormalReporter) BuildStarted ¶
func (r *NormalReporter) BuildStarted(target string)
BuildStarted outputs the target being built.
func (*NormalReporter) CommandOutput ¶
func (r *NormalReporter) CommandOutput(command, stdout, stderr string)
CommandOutput outputs command stdout and stderr. Empty output is suppressed.
func (*NormalReporter) NothingToBuild ¶
func (r *NormalReporter) NothingToBuild(target string)
NothingToBuild outputs that a target is already up to date.
func (*NormalReporter) Summary ¶
func (r *NormalReporter) Summary(total, failed int)
Summary outputs the build summary.
type OutputEvent ¶
type OutputEvent interface {
// contains filtered or unexported methods
}
OutputEvent is the interface that all output events implement. Events are emitted by the build pipeline and rendered by OutputWriters.
type OutputMode ¶
type OutputMode int
OutputMode represents the output context the build tool is running in.
const ( // ModeCLI is for interactive terminal output with colors and formatting. ModeCLI OutputMode = iota // ModeTUI is for structured output consumed by a terminal UI. ModeTUI // ModeHeadless is for CI/CD pipelines and log collectors. ModeHeadless )
func DetectOutputMode ¶
func DetectOutputMode() OutputMode
DetectOutputMode determines the appropriate output mode based on: 1. BUILD_OUTPUT_MODE environment variable (if set) 2. TTY status of stdout/stderr 3. TERM environment variable 4. CI environment indicators
func ParseOutputMode ¶
func ParseOutputMode(s string) OutputMode
ParseOutputMode parses a mode string into OutputMode. Returns ModeCLI for unrecognized values.
func (OutputMode) String ¶
func (m OutputMode) String() string
String returns a human-readable name for the mode.
type OutputWriter ¶
type OutputWriter interface {
// WriteEvent renders an output event to the output stream.
WriteEvent(event OutputEvent)
// Flush ensures all buffered output is written.
Flush()
}
OutputWriter is the interface for rendering build output. Different implementations provide different output styles.
func NewDefaultWriter ¶
func NewDefaultWriter(config WriterConfig) OutputWriter
NewDefaultWriter creates an OutputWriter with automatic mode detection.
func NewNoOpWriter ¶
func NewNoOpWriter() OutputWriter
NewNoOpWriter creates a writer that discards all output. Useful for testing or when output should be suppressed.
func NewWriter ¶
func NewWriter(mode OutputMode, w io.Writer, config WriterConfig) OutputWriter
NewWriter creates an OutputWriter for the given mode and output stream.
func NewWriterWithMode ¶
func NewWriterWithMode(mode OutputMode, config WriterConfig) OutputWriter
NewWriterWithMode creates an OutputWriter for the given mode with auto-detected output stream.
type PhaseCompleted ¶
type PhaseCompleted struct {
Phase string // "parse", "semantic", "eval", "plan", "execute"
Timestamp time.Time // When the phase completed
Duration time.Duration // How long the phase took
}
PhaseCompleted is emitted when a build phase finishes.
type PhaseStarted ¶
type PhaseStarted struct {
Phase string // "parse", "semantic", "eval", "plan", "execute"
Timestamp time.Time // When the phase started
}
PhaseStarted is emitted when a build phase begins.
type ProgressReporter ¶
type ProgressReporter struct {
// contains filtered or unexported fields
}
ProgressReporter implements output formatting for parallel builds. It shows progress counts and currently building targets.
func NewProgressReporter ¶
func NewProgressReporter(w io.Writer, total int) *ProgressReporter
NewProgressReporter creates a new ProgressReporter that writes to w. total is the total number of targets expected to build.
func (*ProgressReporter) BuildCompleted ¶
func (r *ProgressReporter) BuildCompleted(target string, success bool, errMsg string)
BuildCompleted handles target build completion.
func (*ProgressReporter) BuildStarted ¶
func (r *ProgressReporter) BuildStarted(target string)
BuildStarted outputs progress for a target starting to build. Shows "current/total Building target"
func (*ProgressReporter) CommandOutput ¶
func (r *ProgressReporter) CommandOutput(command, stdout, stderr string)
CommandOutput outputs command stdout and stderr (for errors).
func (*ProgressReporter) CurrentlyBuilding ¶
func (r *ProgressReporter) CurrentlyBuilding() []string
CurrentlyBuilding returns the list of currently building targets.
func (*ProgressReporter) NothingToBuild ¶
func (r *ProgressReporter) NothingToBuild(target string)
NothingToBuild outputs that a target is already up to date.
func (*ProgressReporter) Summary ¶
func (r *ProgressReporter) Summary(total, failed int)
Summary outputs the build summary.
type Reporter ¶
type Reporter interface {
// BuildStarted is called when a target build begins.
BuildStarted(target string)
// BuildCompleted is called when a target build finishes.
// success indicates whether the build succeeded.
// errMsg contains the error message if success is false.
BuildCompleted(target string, success bool, errMsg string)
// CommandOutput is called to display command output.
// stdout and stderr contain the respective output streams.
CommandOutput(command, stdout, stderr string)
// Summary is called at the end to show build summary.
// total is the number of targets built, failed is the number that failed.
Summary(total, failed int)
// NothingToBuild is called when a target is already up to date.
NothingToBuild(target string)
}
Reporter defines the interface for build output reporting. Different implementations can provide different output styles (normal, verbose, quiet, etc.).
type StalenessChecked ¶
type StalenessChecked struct {
Target string // Target being checked
Reason string // "src/main.c is newer", "target missing", etc.
Action string // "rebuild", "skip"
}
StalenessChecked is emitted during staleness checking (verbose mode).
type TUIWriter ¶
type TUIWriter struct {
// contains filtered or unexported fields
}
TUIWriter implements OutputWriter for structured terminal UI output. It produces JSON events that can be consumed by a TUI application.
func (*TUIWriter) WriteEvent ¶
func (t *TUIWriter) WriteEvent(event OutputEvent)
WriteEvent outputs a JSON event.
type TargetCompleted ¶
type TargetCompleted struct {
Target string // Target path or name
Success bool // Whether the build succeeded
Duration time.Duration // How long the build took
Error string // Error message if Success is false
}
TargetCompleted is emitted when a target build finishes.
type TargetSkipped ¶
type TargetSkipped struct {
Target string // Target path or name
Reason string // "up to date", "already built", etc.
}
TargetSkipped is emitted when a target is skipped (up to date, etc.).
type TargetStarted ¶
type TargetStarted struct {
Target string // Target path or name
Index int // 1-based index for progress (e.g., 3 of 10)
Total int // Total number of targets
}
TargetStarted is emitted when a target build begins.
type TerminalCapabilities ¶
type TerminalCapabilities struct {
Width int // Terminal width in columns (0 if unknown)
Height int // Terminal height in rows (0 if unknown)
ColorLevel ColorLevel // Supported color level
Unicode bool // Unicode support
Interactive bool // Is an interactive terminal
}
TerminalCapabilities holds detected terminal capabilities.
func DetectCapabilities ¶
func DetectCapabilities() *TerminalCapabilities
DetectCapabilities detects terminal capabilities for stdout.
func (*TerminalCapabilities) SizeWithFallback ¶
func (t *TerminalCapabilities) SizeWithFallback() (width, height int)
SizeWithFallback returns the terminal size, using defaults if unknown.
func (*TerminalCapabilities) Supports256Color ¶
func (t *TerminalCapabilities) Supports256Color() bool
Supports256Color returns true if the terminal supports 256 colors.
func (*TerminalCapabilities) SupportsColor ¶
func (t *TerminalCapabilities) SupportsColor() bool
SupportsColor returns true if the terminal supports any color.
func (*TerminalCapabilities) SupportsTruecolor ¶
func (t *TerminalCapabilities) SupportsTruecolor() bool
SupportsTruecolor returns true if the terminal supports 24-bit color.
type VariableEvaluated ¶
type VariableEvaluated struct {
Name string // Variable name
Expr string // Original expression (if function call, empty for simple values)
Result string // Evaluated value
}
VariableEvaluated is emitted when a variable is evaluated (verbose mode).
type VerboseReporter ¶
type VerboseReporter struct {
// contains filtered or unexported fields
}
VerboseReporter implements output formatting for verbose mode (-v). It shows variable evaluation results, staleness check results, and dependency resolution information in addition to build progress.
func NewVerboseReporter ¶
func NewVerboseReporter(w io.Writer) *VerboseReporter
NewVerboseReporter creates a new VerboseReporter that writes to w.
func (*VerboseReporter) BuildCompleted ¶
func (r *VerboseReporter) BuildCompleted(target string, success bool, errMsg string)
BuildCompleted outputs completion status for a target build.
func (*VerboseReporter) BuildStarted ¶
func (r *VerboseReporter) BuildStarted(target string)
BuildStarted outputs a header for building a target.
func (*VerboseReporter) CommandExecuted ¶
func (r *VerboseReporter) CommandExecuted(command string)
CommandExecuted outputs a command that was executed (indented).
func (*VerboseReporter) CommandOutput ¶
func (r *VerboseReporter) CommandOutput(command, stdout, stderr string)
CommandOutput outputs command stdout and stderr.
func (*VerboseReporter) NothingToBuild ¶
func (r *VerboseReporter) NothingToBuild(target string)
NothingToBuild outputs that a target is already up to date.
func (*VerboseReporter) StalenessCheck ¶
func (r *VerboseReporter) StalenessCheck(target, reason, action string)
StalenessCheck outputs a staleness check result. reason explains why (e.g., "src/main.c is newer", "up to date"). action is the decision (e.g., "rebuild", "skip").
func (*VerboseReporter) StartStalenessChecks ¶
func (r *VerboseReporter) StartStalenessChecks()
StartStalenessChecks outputs a header for the staleness check phase.
func (*VerboseReporter) StartVariableEvaluation ¶
func (r *VerboseReporter) StartVariableEvaluation()
StartVariableEvaluation outputs a header for the variable evaluation phase.
func (*VerboseReporter) Summary ¶
func (r *VerboseReporter) Summary(total, failed int)
Summary outputs the build summary.
func (*VerboseReporter) VariableEvaluated ¶
func (r *VerboseReporter) VariableEvaluated(name, expr, result string)
VariableEvaluated outputs a variable evaluation result. expr is the expression (e.g., "shell(find src -name \"*.c\")"), result is the evaluated value. If expr is empty, only shows "name → result".
type WriterConfig ¶
type WriterConfig struct {
// Verbose enables detailed output (variable evaluation, staleness checks)
Verbose bool
// Quiet suppresses non-error output
Quiet bool
// Color controls color output: "auto", "always", "never"
Color string
// Unicode controls Unicode symbol output: "auto", "always", "never"
// When disabled, ASCII-only symbols are used.
Unicode string
// LogLevel sets minimum log level for headless mode: "debug", "info", "warn", "error"
LogLevel string
// LogFormat sets log format for headless mode: "text", "json"
LogFormat string
}
WriterConfig configures output writer behavior.
func DefaultWriterConfig ¶
func DefaultWriterConfig() WriterConfig
DefaultWriterConfig returns a config with sensible defaults.
func NewWriterConfigFromFlags ¶
func NewWriterConfigFromFlags(verbose, quiet bool, color string) WriterConfig
NewWriterConfigFromFlags creates a WriterConfig from CLI flag values.