Documentation
¶
Index ¶
- Constants
- Variables
- func AutoSizeColumns(headers []string, rows [][]string, padding int, flexCols ...int)
- func ColorDiffLine(line string) string
- func DiffLine(w io.Writer, prefix, color string, format string, args ...any)
- func FormatDuration(d time.Duration) string
- func IsStdinTerminal() bool
- func IsTerminal() bool
- func NormalizeBuildLog(lines []string) []string
- func PlainStatusIcon(status, state string) string
- func PlainStatusText(status, state string) string
- func PrintJSONError(w io.Writer, code JSONErrorCode, message, suggestion string)
- func PrintLogo(w io.Writer)
- func RelativeTime(t time.Time) string
- func RestoreAnsi(s string) string
- func SplitLogLines(log string) []string
- func StatusIcon(status, state string) string
- func StatusText(status, state string) string
- func TerminalSize() (int, int)
- func TerminalWidth() int
- 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) Info(format string, args ...any)
- func (p *Printer) Infof(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) Success(format string, args ...any)
- func (p *Printer) Warn(format string, args ...any)
- type TreeNode
Constants ¶
const Logo = `` /* 229-byte string literal not displayed */
Variables ¶
var ( Green = color.New(color.FgGreen).SprintFunc() Red = color.New(color.FgRed).SprintFunc() Yellow = color.New(color.FgYellow).SprintFunc() Cyan = color.New(color.FgCyan).SprintFunc() Bold = color.New(color.Bold).SprintFunc() Faint = color.New(color.Faint).SprintFunc() )
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 ColorDiffLine ¶ added in v0.9.0
ColorDiffLine applies git-style coloring to a single diff line.
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 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 RestoreAnsi ¶ added in v0.9.0
RestoreAnsi converts TC's space-prefixed ANSI codes to real terminal escape sequences. When color.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 StatusIcon ¶
StatusIcon returns a colored status icon
func StatusText ¶
StatusText returns colored status text
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 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" )
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
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.