Documentation
¶
Overview ¶
Package render provides CLI output rendering with automatic TTY detection. When stdout is a TTY (interactive terminal), output is pretty with colors and boxes. When stdout is not a TTY (piped, agents), output is plain text.
Override with SUBTASK_OUTPUT=plain or SUBTASK_OUTPUT=pretty.
Index ¶
- Variables
- func Bold(s string) string
- func Dim(s string) string
- func Divider()
- func Error(msg string)
- func FormatDuration(d time.Duration) string
- func FormatStageProgression(stages []string, current string) string
- func Highlight(s string) string
- func Info(msg string)
- func PrintBox(content string)
- func PrintKV(pairs ...KV)
- func PrintTable(headers []string, rows [][]string, footer string)
- func PrintTitledBox(title, content string)
- func ProgressBar(done, total int) string
- func Render(o Output)
- func Renderln(o Output)
- func Section(title string)
- func SectionContent(content string)
- func SimpleTable(headers []string, rows [][]string)
- func Status(status string) string
- func Success(msg string)
- func Warning(msg string)
- func Write(w *os.File, s string)
- type Box
- type KV
- type KeyValueList
- type Output
- type ProgressStep
- type Table
- type TaskCard
- type TaskListTable
- type TaskRow
Constants ¶
This section is empty.
Variables ¶
var Pretty bool
Pretty indicates whether to use pretty (styled) output. Set automatically based on TTY detection, can be overridden via env.
Functions ¶
func FormatDuration ¶
FormatDuration formats a duration for display. Returns: Xs, Xm, or XhYm
func FormatStageProgression ¶
FormatStageProgression formats stage names with current highlighted. Plain: "plan → (implement) → review" Pretty: current stage rendered with highlight + bold.
func PrintKV ¶
func PrintKV(pairs ...KV)
PrintKV is a convenience function to print key-value pairs.
func PrintTable ¶
PrintTable is a convenience function to print a table directly.
func PrintTitledBox ¶
func PrintTitledBox(title, content string)
PrintTitledBox prints content in a box with a title.
func ProgressBar ¶
ProgressBar returns a formatted progress string. In plain mode: "3/5" In pretty mode: "███░░ 3/5"
func Section ¶
func Section(title string)
Section prints a section header. Plain: "\n\n─── Title ───\n" Pretty: styled with color
func SectionContent ¶
func SectionContent(content string)
SectionContent prints content under a section (trimmed).
func SimpleTable ¶
SimpleTable prints a minimal table for quick output. In pretty mode, just adds light styling. No box.
Types ¶
type Box ¶
Box wraps content in a box (pretty mode) or returns as-is (plain mode).
func (*Box) RenderPlain ¶
RenderPlain returns the content as-is with optional title.
func (*Box) RenderPretty ¶
RenderPretty renders content in a styled box with optional title.
type KeyValueList ¶
type KeyValueList struct {
Pairs []KV
Indent int // spaces to indent (default 0)
InBox bool // wrap in a box (pretty mode only)
}
KeyValue prints a list of key-value pairs. Plain: "Key: value\n" Pretty: aligned with styled keys
func (*KeyValueList) Print ¶
func (kv *KeyValueList) Print()
Print renders and prints the key-value list.
func (*KeyValueList) RenderPlain ¶
func (kv *KeyValueList) RenderPlain() string
RenderPlain renders key-value pairs as plain text.
func (*KeyValueList) RenderPretty ¶
func (kv *KeyValueList) RenderPretty() string
RenderPretty renders key-value pairs with styling.
type Output ¶
Output is the interface for types that can render themselves in both modes. Implement this for custom output types that need different plain/pretty rendering.
type ProgressStep ¶
ProgressStep represents a step in PROGRESS.json.
type Table ¶
Table renders a table with headers and rows.
func (*Table) RenderPlain ¶
RenderPlain renders the table as plain tab-separated text.
func (*Table) RenderPretty ¶
RenderPretty renders the table with a box border.
type TaskCard ¶
type TaskCard struct {
Name string
Title string
TaskStatus string
Error string
Branch string
BaseBranch string
BaseCommit string
Model string
Reasoning string
Workspace string
Progress string // "3/5" or empty
ProgressSteps []ProgressStep
Workflow string
Stage string // Formatted progression string
TaskDir string // Task directory path (e.g., .subtask/tasks/fix--foo)
Files []string
LinesAdded int // Git diff stats
LinesRemoved int
ChangesStatus string // "", "applied", "missing"
ChangesError string
CommitCount int
CommitError string
ShowCommits bool
ConflictFiles []string
}
TaskCard renders a task details card (for show command).
func (*TaskCard) RenderPlain ¶
RenderPlain renders the task card as plain key-value text.
func (*TaskCard) RenderPretty ¶
RenderPretty renders the task card with styling and box.
type TaskListTable ¶
type TaskListTable struct {
Tasks []TaskRow
}
TaskListTable renders a list of tasks.
func (*TaskListTable) Print ¶
func (t *TaskListTable) Print()
Print renders and prints the task list.
func (*TaskListTable) RenderPlain ¶
func (t *TaskListTable) RenderPlain() string
RenderPlain renders the task list as plain text (for agents).
func (*TaskListTable) RenderPretty ¶
func (t *TaskListTable) RenderPretty() string
RenderPretty renders the task list with styling (for humans). Each task gets two lines: main info + title below.