treeview

package
v0.2.5 Latest Latest
Warning

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

Go to latest
Published: Jan 18, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CountLines

func CountLines(root *Node) int

CountLines returns the number of lines the tree will render.

func SortByOrder

func SortByOrder(jobSet map[string]bool, orderList []string) []string

SortByOrder returns the job names from the set in the order specified by orderList. Jobs in the set that are not in orderList are appended at the end.

func SortJobsByDepth

func SortJobsByDepth(jobNames []string) []string

SortJobsByDepth sorts job names by ':' depth, then alphabetically. Depth is determined by the count of ':' separators in the job name.

Types

type Builder

type Builder struct {
	// contains filtered or unexported fields
}

Builder constructs tree nodes from pipeline data.

func NewBuilder

func NewBuilder(pipelineName string) *Builder

NewBuilder creates a new tree builder.

func (*Builder) AddJob

func (b *Builder) AddJob(job *model.Job, deps []string, jobName string) *TreeNode

AddJob adds a job node to the tree with all its steps.

func (*Builder) AddJobWithSummary

func (b *Builder) AddJobWithSummary(job *model.Job, deps []string, jobName string) *TreeNode

AddJobWithSummary adds a job node to the tree with summarization enabled.

func (*Builder) AddJobWithoutSteps

func (b *Builder) AddJobWithoutSteps(deps []string, jobName string, nested bool) *TreeNode

AddJobWithoutSteps adds a job node to the tree without steps (steps should be added manually afterwards).

func (*Builder) Root

func (b *Builder) Root() *Node

Root returns the root node.

type Display

type Display struct {
	// contains filtered or unexported fields
}

Display manages in-place tree rendering with ANSI cursor control.

func NewDisplay

func NewDisplay() *Display

NewDisplay creates a new display manager.

func (*Display) IsTerminal

func (d *Display) IsTerminal() bool

IsTerminal returns whether stdout is a TTY.

func (*Display) Render

func (d *Display) Render(root *Node)

Render outputs the tree, updating in-place if previously rendered.

func (*Display) RenderStatic

func (d *Display) RenderStatic(root *Node)

RenderStatic displays a static tree view (for list).

type ExecutionTree

type ExecutionTree struct {
	Root *TreeNode
	// contains filtered or unexported fields
}

ExecutionTree holds the entire execution tree.

func NewExecutionTree

func NewExecutionTree(pipelineName string) *ExecutionTree

NewExecutionTree creates a new execution tree with a root node.

func (*ExecutionTree) AddJob

func (et *ExecutionTree) AddJob(job *model.Job) *TreeNode

AddJob adds a job node to the tree.

func (*ExecutionTree) AddJobWithDeps

func (et *ExecutionTree) AddJobWithDeps(jobName string, deps []string) *TreeNode

AddJobWithDeps adds a job node to the tree with dependencies.

func (*ExecutionTree) CountLines

func (et *ExecutionTree) CountLines() int

CountLines returns the number of lines the tree will render.

func (*ExecutionTree) RenderTree

func (et *ExecutionTree) RenderTree() string

RenderTree renders the entire tree to a string (live rendering).

type Node

type Node struct {
	Name         string
	ID           string // Unique identifier (e.g., "job.steps.0", "job.steps.1" for iterations)
	Status       Status
	CreatedAt    time.Time
	UpdatedAt    time.Time
	StartOffset  float64 // Seconds offset from run start
	Duration     float64 // Duration in seconds
	If           string  // Condition that was evaluated (for conditional steps)
	Children     []*Node
	Dependencies []string
	Deferred     bool
	Summarize    bool
	Output       []string // Multi-line output from command execution
	// contains filtered or unexported fields
}

Node represents a node in the tree (job, step, or iteration).

func BuildFromPipeline

func BuildFromPipeline(pipeline *model.Pipeline, resolveDeps func(map[string]*model.Job, string) ([]string, error)) (*Node, error)

BuildFromPipeline constructs a complete tree from a pipeline. Returns the root node ready to be rendered.

func NewCmdNode added in v0.2.4

func NewCmdNode(name string) *Node

NewCmdNode creates a new command node as a child of a step.

func NewJobNode

func NewJobNode(name string, nested bool) *Node

NewJobNode creates a new job node.

func NewNode

func NewNode(name string) *Node

NewNode creates a new tree node.

func NewPendingStepNode added in v0.2.4

func NewPendingStepNode(name string, deferred, summarize bool) *Node

NewPendingStepNode creates a new step node with pending status.

func NewStepNode

func NewStepNode(name string, deferred bool) *Node

NewStepNode creates a new step node.

func (*Node) AddChild

func (n *Node) AddChild(child *Node)

AddChild adds a child node.

func (*Node) AddChildren

func (n *Node) AddChildren(children ...*Node)

AddChildren adds multiple child nodes.

func (*Node) GetChildren

func (n *Node) GetChildren() []*Node

GetChildren returns a copy of the children slice (thread-safe).

func (*Node) HasChildren

func (n *Node) HasChildren() bool

HasChildren returns true or false if the node has children.

func (*Node) Label

func (n *Node) Label() string

func (*Node) SetDuration added in v0.2.4

func (n *Node) SetDuration(duration float64)

SetDuration sets the duration in seconds.

func (*Node) SetIf added in v0.2.4

func (n *Node) SetIf(condition string)

SetIf sets the condition string that was evaluated.

func (*Node) SetOutput

func (n *Node) SetOutput(lines []string)

SetOutput sets the output lines for this node (from command execution).

func (*Node) SetStartOffset added in v0.2.4

func (n *Node) SetStartOffset(offset float64)

SetStartOffset sets the start offset from run start.

func (*Node) SetStatus

func (n *Node) SetStatus(status Status)

SetStatus updates a node's status thread-safely.

func (*Node) StatusColor

func (n *Node) StatusColor() string

type Renderer

type Renderer struct {
	// contains filtered or unexported fields
}

Renderer handles rendering of tree nodes to strings with proper formatting.

func NewRenderer

func NewRenderer() *Renderer

NewRenderer creates a new tree renderer.

func (*Renderer) Render

func (r *Renderer) Render(root *Node) string

Render converts a node to a string representation.

func (*Renderer) RenderStatic

func (r *Renderer) RenderStatic(root *Node) string

RenderStatic renders a static tree (for list views) without spinners.

type Status

type Status int

Status represents the execution status of a node.

const (
	StatusPending Status = iota
	StatusRunning
	StatusPassed
	StatusFailed
	StatusSkipped
	StatusConditional
)

Status constants.

func (Status) Label added in v0.2.4

func (s Status) Label() string

Label returns a lowercase readable label for the Status (for logging/serialization).

func (Status) String

func (s Status) String() string

String returns a colored string representation of the Status for display.

type TreeNode

type TreeNode struct {
	*Node
	// contains filtered or unexported fields
}

TreeNode represents a node in the execution tree (backward compatibility).

func NewTreeNode

func NewTreeNode(name string) *TreeNode

NewTreeNode creates a new tree node.

func (*TreeNode) AddStep

func (job *TreeNode) AddStep(stepName string) *TreeNode

AddStep adds a step node to a job.

func (*TreeNode) AddStepDeferred

func (job *TreeNode) AddStepDeferred(stepName string) *TreeNode

AddStepDeferred adds a deferred step node to a job.

func (*TreeNode) GetChildren

func (node *TreeNode) GetChildren() []*TreeNode

GetChildren returns the children of a node.

func (*TreeNode) GetName

func (node *TreeNode) GetName() string

GetName returns the name of the node.

func (*TreeNode) GetStatus

func (node *TreeNode) GetStatus() Status

GetStatus returns the status of the node.

func (*TreeNode) SetStatus

func (node *TreeNode) SetStatus(status Status)

SetStatus updates a node's status.

Jump to

Keyboard shortcuts

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