go.bigb.es/auxilia

v0.6.0
Doc Versions Source

Documentation

Package report provides human-facing implementations of the legatus Reporter and Prompter interfaces: a text progress reporter and CLI/auto prompters. These are the injectable interactivity/progress impls (PC2): self-contained, no globals, no direct os.Stdin/os.Stdout access — all I/O flows through the configured readers and writers.

Types

T type AutoPrompter

src
type AutoPrompter bool

AutoPrompter is a non-interactive prompter that answers every Confirm with a fixed boolean and every Select with the first option.

m func (AutoPrompter) Confirm

src
func (a AutoPrompter) Confirm(context.Context, string) (bool, error)

Confirm returns the configured fixed answer.

m func (AutoPrompter) Select

src
func (AutoPrompter) Select(_ context.Context, _ string, options []string) (int, error)

Select always picks the first option.

T type CLIPrompter

src
type CLIPrompter struct {
	In  io.Reader
	Out io.Writer
	// contains filtered or unexported fields
}

CLIPrompter answers interactive questions by reading from In and writing prompts to Out. It never touches os.Stdin/os.Stdout directly (PC2).

m func (*CLIPrompter) Confirm

src
func (p *CLIPrompter) Confirm(_ context.Context, question string) (bool, error)

Confirm asks a yes/no question. An empty or unrecognized answer is treated as "no". A read error before any input is returned.

m func (*CLIPrompter) Select

src
func (p *CLIPrompter) Select(_ context.Context, question string, options []string) (int, error)

Select presents numbered options and reads a 1-based choice, returning the 0-based index. A non-numeric or out-of-range answer is an error.

T type Table

src
type Table struct {
	// contains filtered or unexported fields
}

Table is a passive aligned-column renderer for terminal output. Cells may carry ANSI color escapes (e.g. a colored status); column widths are measured on visible runes so a colored cell aligns exactly as its plain twin. It is pure data-in, text-out: no I/O beyond the io.Writer passed to Render, and no dependency on the legatus core, transport, or sync.

f func NewTable

src
func NewTable(headers ...string) *Table

NewTable returns a Table with the given column headers.

m func (*Table) AddRow

src
func (t *Table) AddRow(cells ...string) *Table

AddRow appends a row and returns the table for chaining. A row need not match the header count: shorter rows render the missing cells empty, longer rows add unheadered columns — Render derives the column count from the widest input.

m func (*Table) Render

src
func (t *Table) Render(w io.Writer)

Render writes the aligned table to w. Columns are left-aligned at the widest visible cell, separated by a two-space gutter, with no trailing whitespace and one newline per row. Output is deterministic for a given header+row set: the column order is construction order and no map iteration is involved. Write errors are ignored, matching TextReporter.

T type TextReporter

src
type TextReporter struct {
	W     io.Writer
	Color bool
}

TextReporter writes per-step progress lines and a final summary to W. When Color is set, glyphs are wrapped in ANSI color codes.

m func (*TextReporter) FlowDone

src
func (r *TextReporter) FlowDone(host string, res legatus.FlowResult)

FlowDone reports the aggregate status of a flow on a host.

m func (*TextReporter) FlowStart

src
func (r *TextReporter) FlowStart(host, flow string)

FlowStart announces the start of a flow on a host.

m func (*TextReporter) RunDone

src
func (r *TextReporter) RunDone(res legatus.RunResult)

RunDone writes the final tally across all hosts.

m func (*TextReporter) StepDone

src
func (r *TextReporter) StepDone(host string, res legatus.StepResult)

StepDone reports the outcome of a step with a status glyph.

m func (*TextReporter) StepStart

src
func (r *TextReporter) StepStart(host, step string)

StepStart announces a step about to run on a host.

Source Files