graphcmd

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Apr 3, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

Package graphcmd implements the "graph" CLI command, which renders the issue hierarchy and relationships as a Graphviz DOT file.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewCmd

func NewCmd(f *cmdutil.Factory) *cli.Command

NewCmd constructs the "graph" command, which renders issue relationships in one of several output formats (dot, json, text).

func RenderGraphDOT

func RenderGraphDOT(nodes []GraphNode, edges []GraphEdge) string

RenderGraphDOT generates a Graphviz DOT string from the given nodes and edges. Nodes are color-coded by state. Parent–child hierarchy is represented with solid edges, blocked_by with dashed red edges, and cites with dotted gray edges. Children are clustered under their parent epic using subgraphs.

func RenderGraphJSON

func RenderGraphJSON(nodes []GraphNode, edges []GraphEdge) string

RenderGraphJSON converts a set of nodes and edges into a JSON string representing a nested graph structure. Root issues (those with no parent) appear at the top level; children are recursively nested under their parent. Edges are distributed to both endpoints: a blocked_by edge from A→B appears as blocked_by on A and blocks on B. Cites/cited_by edges are folded under refs.

func Run

func Run(ctx context.Context, input RunInput) error

Run executes the graph workflow: fetches all issues and relationships, filters by visibility, and dispatches to the appropriate format renderer.

Types

type Format

type Format string

Format identifies the output format for the graph command.

const (
	// FormatDOT renders a Graphviz DOT file.
	FormatDOT Format = "dot"
	// FormatJSON renders a nested JSON graph structure.
	FormatJSON Format = "json"
	// FormatText renders an ASCII tree.
	FormatText Format = "text"
)

func ParseFormat

func ParseFormat(s string) (Format, error)

ParseFormat converts a user-provided string into a Format constant. Returns an error for unrecognized values.

type GraphEdge

type GraphEdge struct {
	SourceID domain.ID
	TargetID domain.ID
	Type     domain.RelationType
}

GraphEdge represents a relationship between two issues in the graph.

type GraphNode

type GraphNode struct {
	ID       domain.ID
	Role     domain.Role
	State    domain.State
	Title    string
	ParentID domain.ID
}

GraphNode represents an issue in the graph with the minimum attributes needed for rendering.

type RunInput

type RunInput struct {
	Service       driving.Service
	Format        Format
	IncludeClosed bool
	WriteTo       io.Writer
}

RunInput holds the parameters for the graph command's core logic, decoupled from CLI flag parsing so it can be tested directly.

Jump to

Keyboard shortcuts

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