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.
Render uses the plan's FeatLine for both halves, so the "after" SHAs are a projection (the pre-rebase commits). Callers that want the "after" graph to show the real post-rebase SHAs should render the halves separately (RenderBefore, then re-read the new SHAs into the plan, then RenderAfter).
func (RebasePlan) RenderAfter ¶
func (p RebasePlan) RenderAfter(c Colors) string
RenderAfter draws the "after" half: the feature replayed on top of trunk head. It draws the replayed nodes from FeatLine, so callers should set FeatLine to the real post-rebase commits before calling it (see visualizeRebase).
func (RebasePlan) RenderBefore ¶
func (p RebasePlan) RenderBefore(c Colors) string
RenderBefore draws the "before" half: the feature diverged from trunk.
type Stepper ¶
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.