Documentation
¶
Index ¶
- Constants
- Variables
- func AutoSizeColumns(headers []string, rows [][]string, padding int, flexCols ...int)
- func ClearLine(w io.Writer)
- func ColorDiffLine(line string) string
- func ConsoleSupportsUTF8() bool
- func DiffLine(w io.Writer, prefix, color string, format string, args ...any)
- func FormatDuration(d time.Duration) string
- func FormatTip(tip string) string
- func IsStdinTerminal() bool
- func IsTerminal() bool
- func NormalizeBuildLog(lines []string) []string
- func PlainStatusIcon(status, state string, statusText ...string) string
- func PlainStatusText(status, state string, apiStatusText ...string) string
- func PrintJSONError(w io.Writer, code JSONErrorCode, message, suggestion string)
- func PrintLogo(w io.Writer)
- func RelativeTime(t time.Time) string
- func RenderError(err error) error
- func RestoreAnsi(s string) string
- func SplitLogLines(log string) []string
- func StartSpinner(quiet bool)
- func StatusIcon(status, state string, statusText ...string) string
- func StatusText(status, state string, apiStatusText ...string) string
- func StopSpinner()
- func TerminalSize() (int, int)
- func TerminalWidth() int
- func TestCountsSummary(t *api.TestOccurrences) string
- func TipEnableReadOnly() string
- func TipNoArtifactsFor(runID string) string
- func TipNoCommentFor(runID string) string
- func TipNoLogFor(runID string) string
- func TipNoParametersFor(scope string) string
- func TipNoSettingsFor(scope string) string
- func TipRegisterGitHubApp(owner string) string
- func TipResumeLogFor(runID string) string
- func TipResumeWatchFor(runID string) string
- func TipSwitchDefaultServer() string
- func Truncate(s string, maxLen int) string
- func UnifiedDiff(w io.Writer, a, b []string, fromLabel, toLabel string, context int) (bool, error)
- func WithPager(out io.Writer, fn func(w io.Writer))
- type JSONError
- type JSONErrorCode
- type JSONErrorDetail
- type Printer
- func (p *Printer) Debug(format string, args ...any)
- func (p *Printer) Empty(message, tip string)
- func (p *Printer) Info(format string, args ...any)
- func (p *Printer) PrintField(label, value string)
- func (p *Printer) PrintJSON(data any) error
- func (p *Printer) PrintPlainTable(headers []string, rows [][]string, noHeader bool)
- func (p *Printer) PrintTable(headers []string, rows [][]string)
- func (p *Printer) PrintTree(root TreeNode)
- func (p *Printer) PrintViewHeader(title, webURL string, details func())
- func (p *Printer) Progress(format string, args ...any)
- func (p *Printer) Success(format string, args ...any)
- func (p *Printer) Tip(format string, args ...any)
- func (p *Printer) Warn(format string, args ...any)
- type ProgressWriter
- type Symbols
- type TreeNode
Constants ¶
const ( TipNoRuns = "Try --since 7d for a wider window, or --job to scope to one config" 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.
const Logo = `` /* 229-byte string literal not displayed */
const LogoASCII = `######## ######
## ##
## ##
## ##
## ######`
LogoASCII is the 7-bit fallback wordmark for terminals that can't render Logo.
const TipDockerServiceAccount = "Use a service account / robot user, not a personal password"
TipDockerServiceAccount nudges users away from personal Docker passwords.
Variables ¶
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)) )
var ASCII bool
ASCII restricts output to 7-bit ASCII glyphs when true. Factory.InitOutput writes it from TEAMCITY_ASCII / TERM=dumb / console-codepage detection; tests flip it directly for deterministic golden output. Orthogonal to NoColor: color and glyph repertoire are independent terminal capabilities.
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.
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
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 ClearLine ¶ added in v1.2.0
ClearLine returns the cursor to column 0 and erases the line, wiping a transient spinner or progress line before final output.
func ColorDiffLine ¶ added in v0.9.0
ColorDiffLine applies git-style coloring to a single diff line.
func ConsoleSupportsUTF8 ¶ added in v1.2.0
func ConsoleSupportsUTF8() bool
ConsoleSupportsUTF8 reports whether the active console can render UTF-8. Non-Windows terminals are assumed UTF-8 capable; force ASCII with TEAMCITY_ASCII when that assumption is wrong.
func DiffLine ¶ added in v0.9.0
DiffLine prints a single line with a colored prefix (used for structured diffs).
func FormatDuration ¶
FormatDuration formats a duration in human-readable form
func FormatTip ¶ added in v0.10.0
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 NormalizeBuildLog ¶ added in v0.9.0
NormalizeBuildLog strips per-run noise (header, ANSI, timestamps, temp paths, agent IDs, git progress).
func PlainStatusIcon ¶
PlainStatusIcon returns a plain text status icon (for --plain output).
func PlainStatusText ¶
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 RelativeTime ¶
RelativeTime formats a time as relative to now
func RenderError ¶ added in v0.10.0
RenderError returns a terminal-ready error with a Tip line appended when available.
func RestoreAnsi ¶ added in v0.9.0
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
SplitLogLines splits a log string into \n-terminated lines for difflib.
func StartSpinner ¶ added in v1.2.0
func StartSpinner(quiet bool)
StartSpinner shows a "Loading..." indicator on stdout until StopSpinner or the first byte of output; no-op when quiet, non-terminal, dumb-terminal, or already running, and the first frame waits one 80ms tick so fast work shows nothing.
func StatusIcon ¶
StatusIcon returns a colored status icon. In ASCII mode the glyph degrades to its PlainStatusIcon equivalent while keeping the color.
func StatusText ¶
StatusText returns colored status text.
func StopSpinner ¶ added in v1.2.0
func StopSpinner()
StopSpinner halts the spinner and clears its line; safe to call repeatedly and when nothing is running, so it can guard pagers and raw-terminal takeovers.
func TerminalSize ¶
TerminalSize returns terminal width and height (defaults: 80x24)
func TerminalWidth ¶
func TerminalWidth() int
TerminalWidth returns the terminal width, or 80 as default
func TestCountsSummary ¶ added in v1.2.0
func TestCountsSummary(t *api.TestOccurrences) string
TestCountsSummary renders nonzero passed/failed/muted/ignored counts, colored and joined; empty when all zero.
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
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
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
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
TipNoParametersFor returns the tip for an empty parameter list, pre-filling the scope (project or job ID).
func TipNoSettingsFor ¶ added in v1.2.0
TipNoSettingsFor returns the tip for an empty settings list, pre-filling the scope (job ID).
func TipRegisterGitHubApp ¶ added in v0.10.0
TipRegisterGitHubApp points the user at GitHub's App registration page (manual mode).
func TipResumeLogFor ¶ added in v0.10.0
TipResumeLogFor returns the resume-hint for an interrupted `teamcity run log` follow session.
func TipResumeWatchFor ¶ added in v0.10.0
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 ¶
Truncate truncates a string to maxLen display width, adding "..." if truncated Properly handles unicode and wide characters
func UnifiedDiff ¶ added in v0.9.0
UnifiedDiff writes a colored unified diff between two line slices, returns true if they differ.
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 writing to os.Stdout/os.Stderr, wrapped so the activity spinner clears on the first byte of output.
func (*Printer) Empty ¶ added in v0.10.0
Empty prints an empty-state message with an optional next-step tip.
func (*Printer) PrintField ¶ added in v0.8.1
func (*Printer) PrintPlainTable ¶ added in v0.8.1
func (*Printer) PrintTable ¶ added in v0.8.1
func (*Printer) PrintViewHeader ¶ added in v0.8.1
func (*Printer) Progress ¶ added in v0.10.0
Progress writes an inline progress line to stdout (no newline). Suppressed by --quiet.
type ProgressWriter ¶ added in v1.2.0
type ProgressWriter struct {
// contains filtered or unexported fields
}
ProgressWriter wraps an io.Writer and renders a determinate "name size NN%" bar to out as bytes flow through, throttled to ~10 fps; callers gate it on output.IsTerminal() and a known total.
func NewProgressWriter ¶ added in v1.2.0
func NewProgressWriter(w, out io.Writer, name, size string, total int64, nameWidth int) *ProgressWriter
NewProgressWriter copies to w while drawing progress for name/total to out; size is the human-readable total shown in the bar.
func (*ProgressWriter) Clear ¶ added in v1.2.0
func (p *ProgressWriter) Clear()
Clear erases the progress line.
type Symbols ¶ added in v1.2.0
type Symbols struct {
Check string // success
Cross string // failure
Neutral string // neutral / unknown
Skip string // canceled / skipped
Arrow string // transition / "then"
ArrowLeft string
Bullet string // list item
Sep string // inline separator (callers supply surrounding spaces)
Pipeline string // pipeline marker
Recycle string // rebuilding / shared result
Pinned string
DeltaUp string
DeltaDown string
Ellipsis string
TreeMid string // child with following siblings
TreeEnd string // last child
TreePipe string // vertical run under TreeMid
TreeGap string // blank run under TreeEnd
}
Symbols is the glyph vocabulary for status marks and structural decoration. Sym() returns the Unicode set, or an ASCII-only set when ASCII is true. The ASCII status marks match PlainStatusIcon so both modes share one repertoire.