cli

package
v0.4.1 Latest Latest
Warning

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

Go to latest
Published: Aug 10, 2026 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func PrintDefaults

func PrintDefaults(fs *flag.FlagSet, w io.Writer)

PrintDefaults writes flag defaults using double-dash prefixes.

func ReadInput

func ReadInput(path string) ([]byte, error)

ReadInput reads a --in path, treating "-" as stdin.

func WriteGraph

func WriteGraph(c *Common, g *layout.Graph) error

WriteGraph encodes g as layout JSON to --out, honouring --pretty (the shipping default: indented, trailing newline).

func WriteOutput

func WriteOutput(path string, data []byte) error

WriteOutput writes to a --out path, treating "-" as stdout.

Types

type Common

type Common struct {
	In     string
	Out    string
	Pretty bool
}

Common holds the flags every layout-consuming command shares: --in/--out/--pretty. Their help text and defaults ARE layout-gen's shipping surface — the dev tools inherit it verbatim.

func RegisterCommon

func RegisterCommon(fs *flag.FlagSet) *Common

RegisterCommon registers --in/--out/--pretty on fs and returns the Common whose fields they write. Call it BEFORE registering a tool's addon flags so the shared surface reads first in --help.

type DetectedInput

type DetectedInput struct {
	Type        InputType
	IPMGraph    *model.IpmGraph
	LayoutGraph *layout.Graph
}

DetectedInput contains the parsed input and its detected type.

func DetectInput

func DetectInput(data []byte, filename string) (*DetectedInput, error)

DetectInput attempts to detect and parse the input data. Returns the parsed data and its detected type. Tries detection in this order: 1. File extension (.ipmt, .layout.json, .json) 2. Content structure (layout.Graph has Meta.Bounds, model.IpmGraph has Nodes array) 3. IPMT text parsing as fallback

func LoadGraph

func LoadGraph(c *Common) (*DetectedInput, *layout.Graph, error)

LoadGraph returns the layout graph WITHOUT tracing: generate for ipmt/ipm.json, pass through for an already-laid-out layout.json. This is layout-gen's shipping path — no trace machinery, no report.

func LoadReport

func LoadReport(c *Common) (*l7report.Report, *DetectedInput, error)

LoadReport returns a TRACED report — the dev tools' path. A recorded .debug.json is decoded and replayed (generation SKIPPED); for an ipmt/ipm.json input the engine runs with a collecting trace (every decision recorded); a passed-through layout.json yields a graph-only report (no events — the pipeline did not run, so --why has nothing to narrate, but --table/--edges/--facts still work off the graph).

type InputType

type InputType int

InputType represents the detected input format.

const (
	InputTypeUnknown InputType = iota
	InputTypeIPMT
	InputTypeIPMGraph
	InputTypeLayoutGraph
	// InputTypeDebugJSON is a recorded run (.debug.json) — a dev-tool
	// input handled by LoadReport, not DetectInput (the shipping tools
	// never see it).
	InputTypeDebugJSON
)

Jump to

Keyboard shortcuts

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