go.bigb.es/auxilia

v0.3.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 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