Documentation
¶
Overview ¶
Package render provides terminal output helpers: optional ANSI color, simple aligned tables, and an ASCII commit-graph used to visualize rebases. Color is disabled when color-mode:none is passed or when output is not a terminal.
Index ¶
- func Plain(format string, a ...any) string
- type Colors
- func (c Colors) Bold(s string) string
- func (c Colors) Cyan(s string) string
- func (c Colors) Dim(s string) string
- func (c Colors) Enabled() bool
- func (c Colors) Green(s string) string
- func (c Colors) Magenta(s string) string
- func (c Colors) Red(s string) string
- func (c Colors) Yellow(s string) string
- type Commit
- type RebasePlan
- type Stepper
- type Table
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Colors ¶
type Colors struct {
// contains filtered or unexported fields
}
Colors holds whether ANSI styling is enabled.
func NewColors ¶
NewColors decides whether to colorize. Precedence: an explicit colorMode wins ("none" forces plain, "always" forces color); otherwise a non-empty NO_COLOR environment variable disables color (https://no-color.org); otherwise color follows isTTY.
type Commit ¶
type Commit struct {
Short string // abbreviated sha
Subject string // first line of the commit message
}
Commit is one node in a rebase visualization.
type RebasePlan ¶
type RebasePlan struct {
Feature string // feature branch name (for labels)
Trunk string // trunk branch name (for labels)
Fork Commit
TrunkLine []Commit
FeatLine []Commit
}
RebasePlan describes the move a rebase performs: the feature commits currently hanging off Fork are replayed on top of the trunk commits that landed since.
Trunk = commits on trunk after Fork, up to trunk head (newest first) Feature = the feature's own commits after Fork (newest first) Fork = the common ancestor the feature forked from
func (RebasePlan) Render ¶
func (p RebasePlan) Render(c Colors) string
Render draws a before/after ASCII graph of the rebase. The "before" picture shows the feature diverged from trunk; the "after" picture shows it replayed on top of trunk head. Colors are applied when enabled.
type Stepper ¶ added in v1.8.0
Stepper telegraphs the procedure tbd is about to run and, on a terminal, animates a spinner for its duration. Progress is meant for stderr so stdout stays clean for piping.
func (Stepper) Run ¶ added in v1.8.0
Run announces label, runs fn, and returns fn's error. On a TTY it shows an animated spinner ONLY if fn runs longer than spinDelay, erasing it when done (the command prints its own result). Off a TTY it prints the label once, so the procedure is still telegraphed in logs and CI.