Documentation
¶
Overview ¶
Package cli implements the iterion command-line interface.
Index ¶
- Constants
- func FormatDuration(d time.Duration) string
- func FormatTime(t time.Time) string
- func IsTTY() bool
- func ParseAnswerFlags(flags []string) (map[string]string, error)
- func ParseAnswersFile(path string) (map[string]interface{}, error)
- func ParseVarFlags(flags []string) (map[string]string, error)
- func PrintError(w io.Writer, err error)
- func PromptHumanAnswers(interaction *store.Interaction) (map[string]interface{}, error)
- func RunDiagram(opts DiagramOptions, p *Printer) error
- func RunEditor(ctx context.Context, opts EditorOptions, p *Printer) error
- func RunInit(opts InitOptions, p *Printer) error
- func RunInspect(opts InspectOptions, p *Printer) error
- func RunReport(opts ReportOptions, p *Printer) error
- func RunResumeWithFile(ctx context.Context, iterFile string, opts ResumeOptions, p *Printer) error
- func RunRun(ctx context.Context, opts RunOptions, p *Printer) error
- func RunValidate(path string, p *Printer) error
- func StatusIcon(status string) string
- func Version() string
- type DiagramOptions
- type DiagramResult
- type EditorOptions
- type InitOptions
- type InitResult
- type InspectOptions
- type InspectSection
- type OutputFormat
- type Printer
- type ReportOptions
- type ResumeOptions
- type RunOptions
- type ValidateResult
Constants ¶
const IterationLatest = -1
IterationLatest is the sentinel value of *InspectOptions.Iteration meaning "use the most recently started iteration of (branch, node)".
Variables ¶
This section is empty.
Functions ¶
func FormatDuration ¶
FormatDuration formats a duration for human display.
func ParseAnswerFlags ¶
ParseAnswerFlags parses a slice of "key=value" strings into a map.
func ParseAnswersFile ¶
ParseAnswersFile reads a JSON file containing answer key-value pairs.
func ParseVarFlags ¶
ParseVarFlags parses a slice of "key=value" strings into a map.
func PrintError ¶
StatusIcon returns a human-friendly icon for a run status. PrintError writes a structured error message to w. If the error is a RuntimeError it includes the error code, node, and hint.
func PromptHumanAnswers ¶
func PromptHumanAnswers(interaction *store.Interaction) (map[string]interface{}, error)
PromptHumanAnswers displays the interaction questions and prompts the user for answers interactively via stdin. Returns the answers as a map.
func RunDiagram ¶
func RunDiagram(opts DiagramOptions, p *Printer) error
RunDiagram compiles an .iter file and outputs its Mermaid diagram.
func RunEditor ¶
func RunEditor(ctx context.Context, opts EditorOptions, p *Printer) error
RunEditor starts the editor HTTP server.
func RunInit ¶
func RunInit(opts InitOptions, p *Printer) error
RunInit initializes a directory with an example workflow and environment config.
func RunInspect ¶
func RunInspect(opts InspectOptions, p *Printer) error
RunInspect loads and displays a run's state.
func RunReport ¶
func RunReport(opts ReportOptions, p *Printer) error
RunReport generates a detailed chronological report for a run.
func RunResumeWithFile ¶
RunResumeWithFile resumes a paused run using a workflow file and answers.
func RunRun ¶
func RunRun(ctx context.Context, opts RunOptions, p *Printer) error
RunRun executes a workflow or recipe and reports the outcome.
func RunValidate ¶
RunValidate parses, compiles, and validates an .iter file.
func StatusIcon ¶
Types ¶
type DiagramOptions ¶
type DiagramOptions struct {
File string // .iter file path
View string // "compact" (default), "detailed", or "full"
}
DiagramOptions holds options for the diagram command.
type DiagramResult ¶
type DiagramResult struct {
File string `json:"file"`
WorkflowName string `json:"workflow_name"`
View string `json:"view"`
Mermaid string `json:"mermaid"`
}
DiagramResult holds the output of a diagram command.
type EditorOptions ¶
type EditorOptions struct {
Port int
Bind string // bind address (default "127.0.0.1"); use "0.0.0.0" to expose on LAN
Dir string // working directory (for examples)
StoreDir string // run store directory (default: nearest .iterion ancestor of Dir, or <Dir>/.iterion)
NoBrowser bool // skip opening browser
}
EditorOptions holds options for the editor command.
type InitOptions ¶
type InitOptions struct {
Dir string // target directory (default: ".")
}
InitOptions holds the configuration for the init command.
type InitResult ¶
type InitResult struct {
Dir string `json:"dir"`
FilesCreated []string `json:"files_created"`
FilesSkipped []string `json:"files_skipped"`
}
InitResult holds the outcome for JSON output.
type InspectOptions ¶
type InspectOptions struct {
RunID string
StoreDir string
Events bool // show event log
Full bool // show all details
Node string
Branch string
Iteration *int // nil = unset; -1 = latest started
// ExecutionID is the alternative single-string selector
// ("exec:<branch>:<node>:<iter>"). Mutually exclusive with --node.
ExecutionID string
Section InspectSection
LogTail int
ListNodes bool
}
InspectOptions holds the configuration for the inspect command.
type InspectSection ¶
type InspectSection string
InspectSection enumerates the per-node report buckets the caller can restrict to via --section. Empty value behaves as SectionAll.
const ( SectionAll InspectSection = "all" SectionSummary InspectSection = "summary" SectionEvents InspectSection = "events" SectionTrace InspectSection = "trace" SectionTools InspectSection = "tools" SectionArtifacts InspectSection = "artifacts" SectionInteractions InspectSection = "interactions" SectionLog InspectSection = "log" )
type OutputFormat ¶
type OutputFormat int
OutputFormat controls how results are rendered.
const ( OutputHuman OutputFormat = iota OutputJSON )
type Printer ¶
type Printer struct {
W io.Writer
Format OutputFormat
}
Printer writes structured output in the selected format.
func NewPrinter ¶
func NewPrinter(format OutputFormat) *Printer
NewPrinter creates a Printer writing to stdout.
type ReportOptions ¶
type ReportOptions struct {
RunID string
StoreDir string
Output string // output file path (empty = stdout)
}
ReportOptions holds the configuration for the report command.
type ResumeOptions ¶
type ResumeOptions struct {
RunID string
StoreDir string
AnswersFile string // path to JSON answers file
Answers map[string]string // --answer key=value overrides
LogLevel string // log level (default: "info", env: ITERION_LOG_LEVEL)
Force bool // allow resume despite workflow hash change
Executor runtime.NodeExecutor
// Background marks this invocation as a managed-runner subprocess
// spawned by the editor server. The CLI writes a .pid file so the
// server can detect liveness across its own restart.
Background bool
}
ResumeOptions holds the configuration for the resume command.
type RunOptions ¶
type RunOptions struct {
File string // .iter file path
Recipe string // recipe JSON file path (alternative to File)
Vars map[string]string // --var key=value overrides
RunID string // explicit run ID (auto-generated if empty)
StoreDir string // store directory (default: nearest .iterion ancestor of the .iter file, or alongside it)
Timeout time.Duration // maximum run duration (0 = no limit)
LogLevel string // log level (default: "info", env: ITERION_LOG_LEVEL)
NoInteractive bool // disable interactive TTY prompting on human pause
Executor runtime.NodeExecutor // pluggable executor (nil = stub)
// Background marks this invocation as a managed-runner subprocess
// spawned by the editor server. The CLI writes a .pid file so the
// server can detect liveness across its own restart, and forces
// NoInteractive (no TTY in the spawned process).
Background bool
// MergeInto controls the worktree-finalization fast-forward target
// for `worktree: auto` runs. "" or "current" → FF the user's
// currently-checked-out branch (default); "none" → skip FF;
// <branch-name> → FF that branch (must match currently-checked-out).
MergeInto string
// BranchName overrides the default storage branch
// `iterion/run/<friendly>` created on the worktree's HEAD. The
// branch is always created (GC guard); on collision a numeric
// suffix is appended.
BranchName string
}
RunOptions holds the configuration for the run command.
type ValidateResult ¶
type ValidateResult struct {
File string `json:"file"`
Valid bool `json:"valid"`
WorkflowName string `json:"workflow_name,omitempty"`
NodeCount int `json:"node_count,omitempty"`
EdgeCount int `json:"edge_count,omitempty"`
ParseDiagnostics []string `json:"parse_diagnostics,omitempty"`
CompileDiagnostics []string `json:"compile_diagnostics,omitempty"`
}
ValidateResult holds the outcome of a validate command.