output

package
v1.1.6 Latest Latest
Warning

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

Go to latest
Published: Jun 28, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package output provides color-aware terminal output utilities for SSU.

Color definitions are centralized here. fatih/color handles NO_COLOR, TERM=dumb, and non-TTY detection automatically -- no custom logic needed.

Index

Constants

View Source
const (
	Check    = "\u2713" // checkmark
	Cross    = "\u2717" // ballot x
	Arrow    = "\u2192" // rightwards arrow
	Bullet   = "\u25CF" // black circle
	Pipe     = "\u2502" // box drawings light vertical
	Ellipsis = "\u2026" // horizontal ellipsis
)

Unicode symbol constants for terminal output. These are plain strings -- callers apply color via the output package.

Variables

View Source
var (
	Success = color.New(color.FgGreen)
	Error   = color.New(color.FgRed)
	Warning = color.New(color.FgYellow)
	Info    = color.New(color.FgCyan)
	Muted   = color.New(color.FgHiBlack) // Gray for secondary text
	Bold    = color.New(color.Bold)
)

General-purpose colors.

View Source
var (
	Pending  = color.New(color.FgGreen)   // Submodule needs update
	Current  = color.New(color.FgCyan)    // Up to date
	Modified = color.New(color.FgYellow)  // Has local changes
	Ahead    = color.New(color.FgMagenta) // Unpushed commits
	Conflict = color.New(color.FgRed)     // Merge conflict
)

Status-specific colors matching the bash version semantics.

Functions

func ForceDisableColor

func ForceDisableColor()

ForceDisableColor explicitly turns off all color output.

func IsColorEnabled

func IsColorEnabled() bool

IsColorEnabled returns whether color output is active. fatih/color handles NO_COLOR, TERM=dumb, and non-TTY automatically.

func IsTTY

func IsTTY() bool

IsTTY returns whether stdout is connected to a terminal. This uses mattn/go-isatty for accurate detection, not just color.NoColor (a pipe with NO_COLOR unset should still detect non-TTY).

Types

type Printer

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

Printer provides formatted output helpers with color and symbols. It respects whatever color state fatih/color is in (NO_COLOR, TTY detection happen at the fatih/color level, not here).

func NewPrinter

func NewPrinter(w io.Writer) *Printer

NewPrinter creates a Printer that writes to w.

func (*Printer) Error

func (p *Printer) Error(msg string)

Error prints a red cross followed by the message.

func (*Printer) Errorf

func (p *Printer) Errorf(format string, args ...any)

Errorf prints a red cross followed by a formatted message.

func (*Printer) Info

func (p *Printer) Info(msg string)

Info prints a cyan bullet followed by the message.

func (*Printer) Infof

func (p *Printer) Infof(format string, args ...any)

Infof prints a cyan bullet followed by a formatted message.

func (*Printer) Success

func (p *Printer) Success(msg string)

Success prints a green checkmark followed by the message.

func (*Printer) Successf

func (p *Printer) Successf(format string, args ...any)

Successf prints a green checkmark followed by a formatted message.

func (*Printer) Warning

func (p *Printer) Warning(msg string)

Warning prints a yellow arrow followed by the message.

func (*Printer) Warningf

func (p *Printer) Warningf(format string, args ...any)

Warningf prints a yellow arrow followed by a formatted message.

Jump to

Keyboard shortcuts

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