status

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Jan 10, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsTTY

func IsTTY(fd uintptr) bool

IsTTY checks if the given file descriptor is a terminal.

Types

type Reporter

type Reporter interface {
	// Start initializes the reporter.
	// Called at the beginning of the analysis pipeline.
	Start()

	// Update shows a simple status message.
	// Example: status.Update("[PARSE] Discovering Go files...")
	Update(message string)

	// UpdateProgress shows a status message with progress counter.
	// Example: status.UpdateProgress("[COVERAGE] Running tests", 5, 23, "pkg/name")
	// Displays as: "[COVERAGE] Running tests... (5/23) pkg/name"
	UpdateProgress(prefix string, current, total int, detail string)

	// Clear removes the current status line from the display.
	// Called before final output to ensure clean output.
	Clear()

	// Stop performs cleanup and finalizes the reporter.
	// Called at the end of the analysis pipeline.
	Stop()
}

Reporter is the interface for progress reporting during analysis.

Components can use this interface to report their status without coupling to specific output implementations. The orchestrator creates an appropriate implementation based on configuration and TTY detection.

Implementations:

  • TTYReporter: Shows live updates to stderr when running in a terminal
  • SilentReporter: No-op implementation for non-TTY or quiet mode
  • TestReporter: Captures messages for testing

func NewReporter

func NewReporter(cfg *config.OutputConfig) Reporter

NewReporter creates an appropriate Reporter based on configuration and TTY detection.

Returns:

  • TTYReporter: If stderr is a TTY and status is enabled
  • SilentReporter: If stderr is not a TTY, quiet mode is on, or output is redirected

Logic:

  1. If QuietMode is true: return SilentReporter
  2. If ShowStatus is true: return TTYReporter (force enable)
  3. If OutputFile is set: return SilentReporter (output redirected)
  4. If stderr is a TTY: return TTYReporter
  5. Otherwise: return SilentReporter (piped/redirected)

type SilentReporter

type SilentReporter struct{}

SilentReporter implements Reporter with no-op methods. Used when output is piped, redirected, or quiet mode is enabled.

func NewSilentReporter

func NewSilentReporter() *SilentReporter

NewSilentReporter creates a new SilentReporter.

func (*SilentReporter) Clear

func (s *SilentReporter) Clear()

Clear is a no-op.

func (*SilentReporter) Start

func (s *SilentReporter) Start()

Start is a no-op.

func (*SilentReporter) Stop

func (s *SilentReporter) Stop()

Stop is a no-op.

func (*SilentReporter) Update

func (s *SilentReporter) Update(message string)

Update is a no-op.

func (*SilentReporter) UpdateProgress

func (s *SilentReporter) UpdateProgress(prefix string, current, total int, detail string)

UpdateProgress is a no-op.

type TTYReporter

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

TTYReporter implements Reporter for terminal output. Writes live status updates to stderr using single-line overwrites.

func NewTTYReporter

func NewTTYReporter() *TTYReporter

NewTTYReporter creates a new TTYReporter.

func (*TTYReporter) Clear

func (t *TTYReporter) Clear()

Clear removes the current status line from stderr.

func (*TTYReporter) Start

func (t *TTYReporter) Start()

Start initializes the reporter (no-op for TTY).

func (*TTYReporter) Stop

func (t *TTYReporter) Stop()

Stop performs cleanup (clears the line and prints newline).

func (*TTYReporter) Update

func (t *TTYReporter) Update(message string)

Update writes a simple status message to stderr. Uses \r to overwrite the current line.

func (*TTYReporter) UpdateProgress

func (t *TTYReporter) UpdateProgress(prefix string, current, total int, detail string)

UpdateProgress writes a status message with progress counter. Format: "{prefix}... ({current}/{total}) {detail}"

type TestReporter

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

TestReporter implements Reporter for testing. Captures all status messages in a slice for verification.

func NewTestReporter

func NewTestReporter() *TestReporter

NewTestReporter creates a new TestReporter.

func (*TestReporter) Clear

func (t *TestReporter) Clear()

Clear records a clear operation.

func (*TestReporter) GetMessages

func (t *TestReporter) GetMessages() []string

GetMessages returns all captured messages.

func (*TestReporter) Start

func (t *TestReporter) Start()

Start records that the reporter was started.

func (*TestReporter) Stop

func (t *TestReporter) Stop()

Stop records that the reporter was stopped.

func (*TestReporter) Update

func (t *TestReporter) Update(message string)

Update captures a simple status message.

func (*TestReporter) UpdateProgress

func (t *TestReporter) UpdateProgress(prefix string, current, total int, detail string)

UpdateProgress captures a progress message.

func (*TestReporter) WasStarted

func (t *TestReporter) WasStarted() bool

WasStarted returns whether Start() was called.

func (*TestReporter) WasStopped

func (t *TestReporter) WasStopped() bool

WasStopped returns whether Stop() was called.

Jump to

Keyboard shortcuts

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