render

package
v0.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 29, 2026 License: MIT Imports: 9 Imported by: 0

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

Constants

This section is empty.

Variables

View Source
var Pretty bool

Pretty indicates whether to use pretty (styled) output. Set automatically based on TTY detection, can be overridden via env.

Functions

func Bold

func Bold(s string) string

Bold returns text in bold (pretty mode) or unchanged (plain mode).

func Dim

func Dim(s string) string

Dim returns dimmed text (pretty mode) or unchanged (plain mode).

func Divider

func Divider()

Divider prints a horizontal divider line.

func Error

func Error(msg string)

Error prints an error message to stderr.

func FormatDuration

func FormatDuration(d time.Duration) string

FormatDuration formats a duration for display. Returns: Xs, Xm, or XhYm

func FormatStageProgression

func FormatStageProgression(stages []string, current string) string

FormatStageProgression formats stage names with current highlighted. Plain: "plan → (implement) → review" Pretty: current stage rendered with highlight + bold.

func Highlight

func Highlight(s string) string

Highlight returns highlighted text (pretty mode) or unchanged (plain mode).

func Info

func Info(msg string)

Info prints an informational message.

func PrintBox

func PrintBox(content string)

PrintBox prints content optionally in a box.

func PrintKV

func PrintKV(pairs ...KV)

PrintKV is a convenience function to print key-value pairs.

func PrintTable

func PrintTable(headers []string, rows [][]string, footer string)

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

func ProgressBar(done, total int) string

ProgressBar returns a formatted progress string. In plain mode: "3/5" In pretty mode: "███░░ 3/5"

func Render

func Render(o Output)

Render outputs an Output type using the appropriate mode.

func Renderln

func Renderln(o Output)

Renderln outputs an Output type with a trailing newline.

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

func SimpleTable(headers []string, rows [][]string)

SimpleTable prints a minimal table for quick output. In pretty mode, just adds light styling. No box.

func Status

func Status(status string) string

Status returns a styled status string.

func Success

func Success(msg string)

Success prints a success message with checkmark.

func Warning

func Warning(msg string)

Warning prints a warning message to stderr.

func Write

func Write(w *os.File, s string)

Write is a helper for writing styled output to a writer.

Types

type Box

type Box struct {
	Title   string
	Content string
}

Box wraps content in a box (pretty mode) or returns as-is (plain mode).

func (*Box) Print

func (b *Box) Print()

Print renders and prints the box.

func (*Box) RenderPlain

func (b *Box) RenderPlain() string

RenderPlain returns the content as-is with optional title.

func (*Box) RenderPretty

func (b *Box) RenderPretty() string

RenderPretty renders content in a styled box with optional title.

type KV

type KV struct {
	Key   string
	Value string
}

KV represents a key-value pair for display.

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

type Output interface {
	RenderPlain() string
	RenderPretty() string
}

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

type ProgressStep struct {
	Step string
	Done bool
}

ProgressStep represents a step in PROGRESS.json.

type Table

type Table struct {
	Headers []string
	Rows    [][]string
	Footer  string // Optional footer line (shown below table)
}

Table renders a table with headers and rows.

func (*Table) Print

func (t *Table) Print()

Print renders and prints the table.

func (*Table) RenderPlain

func (t *Table) RenderPlain() string

RenderPlain renders the table as plain tab-separated text.

func (*Table) RenderPretty

func (t *Table) RenderPretty() string

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) Print

func (c *TaskCard) Print()

Print renders and prints the task card.

func (*TaskCard) RenderPlain

func (c *TaskCard) RenderPlain() string

RenderPlain renders the task card as plain key-value text.

func (*TaskCard) RenderPretty

func (c *TaskCard) RenderPretty() string

RenderPretty renders the task card with styling and box.

type TaskListTable

type TaskListTable struct {
	Tasks  []TaskRow
	Footer string
}

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.

type TaskRow

type TaskRow struct {
	Name          string
	Status        string
	Stage         string
	Progress      string // "X/Y" format
	LastActive    string
	Title         string
	LinesAdded    int // Git diff stats
	LinesRemoved  int
	ChangesStatus string // "", "applied", "missing"
}

TaskRow represents a task for display in the list.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL