output

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: May 6, 2026 License: Apache-2.0 Imports: 22 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TipNoRuns         = "Try --since 7d for a wider window, or --all for everything"
	TipNoFavoriteRuns = "Pin a run with 'teamcity run pin <id>'"
	TipNoAgents       = "Check connectivity or run 'teamcity auth status'"
	TipNoProjects     = "Check your permissions or run 'teamcity auth status'"
	TipNoJobs         = "Verify the project with 'teamcity project list'"
	TipNoPipelines    = "Enable pipelines on the server, or check 'teamcity project list'"
	TipNoQueue        = "Nothing is queued; 'teamcity run list' shows recent runs"
	TipNoPools        = "Contact your administrator to create an agent pool"
	TipNoConnections  = "Create one with 'teamcity project connection create github-app' or 'docker'"
	TipCancelAnytime  = "Press Ctrl+C at any time to cancel"
)

Empty-state tip constants — one canonical copy per list surface.

View Source
View Source
const TipDockerServiceAccount = "Use a service account / robot user, not a personal password"

TipDockerServiceAccount nudges users away from personal Docker passwords.

Variables

View Source
var (
	Green  = wrap(ansiRenderer.NewStyle().Foreground(lipgloss.Color("2")))
	Red    = wrap(ansiRenderer.NewStyle().Foreground(lipgloss.Color("1")))
	Yellow = wrap(ansiRenderer.NewStyle().Foreground(lipgloss.Color("3")))
	Cyan   = wrap(ansiRenderer.NewStyle().Foreground(lipgloss.Color("6")))
	Bold   = wrap(ansiRenderer.NewStyle().Bold(true))
	Faint  = wrap(ansiRenderer.NewStyle().Faint(true))
)
View Source
var NoColor bool

NoColor disables ANSI styling when true. Factory.InitOutput writes it from NO_COLOR / TEAMCITY_NO_COLOR / FORCE_COLOR / --no-color / TTY detection; tests flip it directly for deterministic golden output.

View Source
var TCAnsiRe = regexp.MustCompile(`\x1b\[[0-9;]*[a-zA-Z]| \[[0-9;]*m`)

TCAnsiRe matches real ESC sequences and TC's space-prefixed ANSI codes (` [33m` instead of `\x1b[33m`).

Functions

func AutoSizeColumns added in v0.5.0

func AutoSizeColumns(headers []string, rows [][]string, padding int, flexCols ...int)

AutoSizeColumns truncates flexible columns in-place to fit the terminal width. Fixed columns keep their natural width; the remaining space goes to flex columns.

func ColorDiffLine added in v0.9.0

func ColorDiffLine(line string) string

ColorDiffLine applies git-style coloring to a single diff line.

func DiffLine added in v0.9.0

func DiffLine(w io.Writer, prefix, color string, format string, args ...any)

DiffLine prints a single line with a colored prefix (used for structured diffs).

func FormatDuration

func FormatDuration(d time.Duration) string

FormatDuration formats a duration in human-readable form

func FormatTip added in v0.10.0

func FormatTip(tip string) string

FormatTip returns "Tip: <text>" with a Yellow prefix (plain when NO_COLOR).

func IsStdinTerminal

func IsStdinTerminal() bool

IsStdinTerminal returns true if stdin is a terminal

func IsTerminal

func IsTerminal() bool

IsTerminal returns true if stdout is a terminal.

func NormalizeBuildLog added in v0.9.0

func NormalizeBuildLog(lines []string) []string

NormalizeBuildLog strips per-run noise (header, ANSI, timestamps, temp paths, agent IDs, git progress).

func PlainStatusIcon

func PlainStatusIcon(status, state string, statusText ...string) string

PlainStatusIcon returns a plain text status icon (for --plain output).

func PlainStatusText

func PlainStatusText(status, state string, apiStatusText ...string) string

PlainStatusText returns plain status text (for --plain output).

func PrintJSONError added in v0.9.0

func PrintJSONError(w io.Writer, code JSONErrorCode, message, suggestion string)

PrintJSONError writes a structured JSON error to w.

func PrintLogo(w io.Writer)

func RelativeTime

func RelativeTime(t time.Time) string

RelativeTime formats a time as relative to now

func RenderError added in v0.10.0

func RenderError(err error) error

RenderError returns a terminal-ready error with a Tip line appended when available.

func RestoreAnsi added in v0.9.0

func RestoreAnsi(s string) string

RestoreAnsi converts TC's space-prefixed ANSI codes to real terminal escape sequences. When NoColor is true (non-TTY or --no-color), all ANSI sequences are stripped instead.

func SplitLogLines added in v0.9.0

func SplitLogLines(log string) []string

SplitLogLines splits a log string into \n-terminated lines for difflib.

func StatusIcon

func StatusIcon(status, state string, statusText ...string) string

StatusIcon returns a colored status icon.

func StatusText

func StatusText(status, state string, apiStatusText ...string) string

StatusText returns colored status text.

func TerminalSize

func TerminalSize() (int, int)

TerminalSize returns terminal width and height (defaults: 80x24)

func TerminalWidth

func TerminalWidth() int

TerminalWidth returns the terminal width, or 80 as default

func TipEnableReadOnly added in v0.10.0

func TipEnableReadOnly() string

TipEnableReadOnly returns a tip suggesting how to switch the CLI into read-only mode.

func TipNoArtifactsFor added in v0.10.0

func TipNoArtifactsFor(runID string) string

TipNoArtifactsFor returns the tip for a run that has no artifacts, pointing at the specific run's log command so the user can copy-paste it.

func TipNoCommentFor added in v0.10.0

func TipNoCommentFor(runID string) string

TipNoCommentFor returns the tip for a run with no comment, pre-filling the specific run ID in the suggested command.

func TipNoLogFor added in v0.10.0

func TipNoLogFor(runID string) string

TipNoLogFor returns the tip for a run with no log yet, pointing at the specific run's view command.

func TipNoParametersFor added in v0.10.0

func TipNoParametersFor(scope string) string

TipNoParametersFor returns the tip for an empty parameter list, pre-filling the scope (project or job ID).

func TipRegisterGitHubApp added in v0.10.0

func TipRegisterGitHubApp(owner string) string

TipRegisterGitHubApp points the user at GitHub's App registration page (manual mode).

func TipResumeLogFor added in v0.10.0

func TipResumeLogFor(runID string) string

TipResumeLogFor returns the resume-hint for an interrupted `teamcity run log` follow session.

func TipResumeWatchFor added in v0.10.0

func TipResumeWatchFor(runID string) string

TipResumeWatchFor returns the resume-hint for an interrupted `teamcity run watch` session.

func TipSwitchDefaultServer added in v0.10.0

func TipSwitchDefaultServer() string

TipSwitchDefaultServer returns a tip pointing at the command that switches the default server.

func Truncate

func Truncate(s string, maxLen int) string

Truncate truncates a string to maxLen display width, adding "..." if truncated Properly handles unicode and wide characters

func UnifiedDiff added in v0.9.0

func UnifiedDiff(w io.Writer, a, b []string, fromLabel, toLabel string, context int) (bool, error)

UnifiedDiff writes a colored unified diff between two line slices, returns true if they differ.

func WithPager

func WithPager(out io.Writer, fn func(w io.Writer))

WithPager pipes output through less if it exceeds terminal height. The out writer is used as a fallback when paging is not available.

Types

type JSONError added in v0.9.0

type JSONError struct {
	Error JSONErrorDetail `json:"error"`
}

JSONError is the structured error envelope emitted when --json is active.

type JSONErrorCode added in v0.9.0

type JSONErrorCode string

JSONErrorCode identifies the category of a structured JSON error.

const (
	ErrCodeAuth       JSONErrorCode = "auth_expired"
	ErrCodePermission JSONErrorCode = "permission_denied"
	ErrCodeNotFound   JSONErrorCode = "not_found"
	ErrCodeNetwork    JSONErrorCode = "network_error"
	ErrCodeReadOnly   JSONErrorCode = "read_only"
	ErrCodeValidation JSONErrorCode = "validation_error"
	ErrCodeInternal   JSONErrorCode = "internal_error"
)

func ClassifyError added in v0.10.0

func ClassifyError(err error) (JSONErrorCode, string, string)

ClassifyError maps an error to a JSON error envelope (code + message + tip).

type JSONErrorDetail added in v0.9.0

type JSONErrorDetail struct {
	Code       JSONErrorCode `json:"code"`
	Message    string        `json:"message"`
	Suggestion string        `json:"suggestion,omitempty"`
}

JSONErrorDetail holds the fields inside the "error" key.

type Printer added in v0.8.1

type Printer struct {
	Out     io.Writer
	ErrOut  io.Writer
	Quiet   bool
	Verbose bool
	// contains filtered or unexported fields
}

Printer writes formatted output respecting Quiet/Verbose flags.

func DefaultPrinter added in v0.8.1

func DefaultPrinter() *Printer

DefaultPrinter returns a Printer that writes to os.Stdout/os.Stderr.

func (*Printer) Debug added in v0.8.1

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

func (*Printer) Empty added in v0.10.0

func (p *Printer) Empty(message, tip string)

Empty prints an empty-state message with an optional next-step tip.

func (*Printer) Info added in v0.8.1

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

func (*Printer) PrintField added in v0.8.1

func (p *Printer) PrintField(label, value string)

func (*Printer) PrintJSON added in v0.8.1

func (p *Printer) PrintJSON(data any) error

func (*Printer) PrintPlainTable added in v0.8.1

func (p *Printer) PrintPlainTable(headers []string, rows [][]string, noHeader bool)

func (*Printer) PrintTable added in v0.8.1

func (p *Printer) PrintTable(headers []string, rows [][]string)

func (*Printer) PrintTree added in v0.8.1

func (p *Printer) PrintTree(root TreeNode)

func (*Printer) PrintViewHeader added in v0.8.1

func (p *Printer) PrintViewHeader(title, webURL string, details func())

func (*Printer) Progress added in v0.10.0

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

Progress writes an inline progress line to stdout (no newline). Suppressed by --quiet.

func (*Printer) Success added in v0.8.1

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

func (*Printer) Tip added in v0.10.0

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

Tip prints a "Tip: <text>" line for next-step guidance on non-error events.

func (*Printer) Warn added in v0.8.1

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

type TreeNode added in v0.7.0

type TreeNode struct {
	Label    string
	Children []TreeNode
}

TreeNode represents a node in a displayable tree.

Jump to

Keyboard shortcuts

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