Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ColorProfile ¶
type ColorProfile int
ColorProfile represents terminal color capabilities.
const ( ColorNone ColorProfile = iota // No color support Color16 // 16 colors (basic ANSI) Color256 // 256 colors ColorTrue // Truecolor (16 million colors) )
func (ColorProfile) String ¶
func (c ColorProfile) String() string
String returns the string representation of ColorProfile.
type Config ¶
type Config struct {
// From CLI flags
NoColor bool
Color bool
ForceColor bool
ForceTTY bool
// From environment variables
EnvNoColor bool // NO_COLOR
EnvCLIColor string // CLICOLOR
EnvCLIColorForce bool // CLICOLOR_FORCE
EnvTerm string // TERM
EnvColorTerm string // COLORTERM
// From atmos.yaml
AtmosConfig schema.AtmosConfiguration
}
Config holds terminal configuration from various sources.
func (*Config) DetectColorProfile ¶
func (c *Config) DetectColorProfile(isTTY bool) ColorProfile
DetectColorProfile determines the terminal's color capabilities.
func (*Config) ShouldUseColor ¶
ShouldUseColor determines if color should be used based on config priority. Priority (highest to lowest): 1. NO_COLOR env var - disables all color 2. CLICOLOR=0 - disables color (unless CLICOLOR_FORCE or --force-color is set) 3. CLICOLOR_FORCE - forces color even for non-TTY 4. --force-color flag - forces color even for non-TTY 5. --no-color flag - disables color 6. --color flag - enables color (only if TTY) 7. Atmos.yaml terminal.no_color (deprecated) - disables color 8. Atmos.yaml terminal.color - enables color (only if TTY) 9. Default (true for TTY, false for non-TTY).
type IOStream ¶
type IOStream int
IOStream represents an I/O stream type for terminal operations. This mirrors io.Stream but avoids circular dependency.
type IOWriter ¶
type IOWriter interface {
// Write outputs content to the specified stream with automatic masking.
// stream values: 0=Data (stdout), 1=UI (stderr)
Write(stream int, content string) error
}
IOWriter is the interface for writing to I/O streams. This avoids circular dependency with pkg/io. The stream parameter uses int to allow different packages to define their own stream types.
type Option ¶
type Option func(*terminal)
Option configures Terminal.
func WithConfig ¶
WithConfig sets a custom config (for testing).
type Terminal ¶
type Terminal interface {
// Write outputs UI content to the terminal.
// Content flows: terminal.Write() → io.Write(UIStream) → masking → stderr
Write(content string) error
// IsTTY returns whether the given stream is a TTY.
IsTTY(stream Stream) bool
// ColorProfile returns the terminal's color capabilities.
ColorProfile() ColorProfile
// Width returns the terminal width for the given stream.
// Returns 0 if width cannot be determined.
Width(stream Stream) int
// Height returns the terminal height for the given stream.
// Returns 0 if height cannot be determined.
Height(stream Stream) int
// SetTitle sets the terminal window title (if supported).
// Does nothing if terminal doesn't support titles or if disabled in config.
SetTitle(title string)
// RestoreTitle restores the original terminal title.
RestoreTitle()
// Alert emits a terminal bell/alert (if enabled).
Alert()
}
Terminal provides terminal capability detection and operations. Terminal writes UI output through the I/O layer for automatic masking.