Documentation
¶
Overview ¶
Package progress provides structured status reporting for the derive flow.
Index ¶
- type Event
- type Status
- type Writer
- func (pw *Writer) Countdown(providerName, waitingMsg, detail string, remaining time.Duration)
- func (pw *Writer) Emit(e Event)
- func (pw *Writer) Fatal(msg string)
- func (pw *Writer) FinishLine()
- func (pw *Writer) Info(msg string)
- func (pw *Writer) Link(prefix, url string)
- func (pw *Writer) PromptLine(providerType, label, hint string) (string, error)
- func (pw *Writer) PromptPassword(providerType, label, hint string) (string, error)
- func (pw *Writer) Starting(providerName, id, msg string)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Event ¶
type Event struct {
Provider string // provider type, e.g. "ssh-agent", "fido2"
ID string // provider config ID, e.g. "fido2-1"
Status Status
Message string // e.g. "waiting for touch...", "no keys loaded", "timeout"
}
Event is emitted to report provider progress during derivation.
type Writer ¶
type Writer struct {
// contains filtered or unexported fields
}
Writer formats and emits progress lines to an io.Writer (typically stderr).
func New ¶
New creates a Writer.
isTTY indicates whether the writer's target is a terminal. noTUI, if true, forces plain-line output even on a TTY (script mode). quiet suppresses all non-fatal output.
When both isTTY and !noTUI are true, the Writer renders colors, in-place countdowns, and raw-mode inline prompts. Otherwise it falls back to plain stdin reads and line-based output.
func (*Writer) Countdown ¶
Countdown overwrites the current line with a provider-specific waiting message followed by the remaining seconds. When detail is non-empty it is embedded inline next to the message with an arrow separator ("waiting for browser → http://localhost:N/") so the actionable text is obvious without the user having to scan to the edge of the terminal. The hint ("esc skip • ctrl+c quit") is kept when it fits, dropped when the line would overflow. No-op when the output isn't interactive.
func (*Writer) Emit ¶
Emit writes a progress event as a single line. In interactive mode the committed statuses (Succeeded / Failed / Skipped) clear any pending transient line with \r\033[2K first, so they don't visually collide with a Waiting event or countdown that lacked a trailing newline.
func (*Writer) FinishLine ¶
func (pw *Writer) FinishLine()
FinishLine clears the current in-place line and moves to a new line, so the next Emit starts clean. Call after a waiting/countdown sequence.
func (*Writer) Info ¶
Info writes a message on its own line, clearing any in-progress countdown line first so the output doesn't collide. The countdown ticker will re-paint on its next tick.
func (*Writer) Link ¶
Link writes a labeled URL where the URL portion is rendered in dim styling on interactive terminals.
func (*Writer) PromptLine ¶
PromptLine prompts for a plain echoed line (e.g. a file path).
func (*Writer) PromptPassword ¶
PromptPassword prompts for a secret with masked bullets. hint is rendered in dim text next to the label (e.g. "esc to skip") and may be empty.
func (*Writer) Starting ¶
Starting emits a committed "starting" line for a provider. Used by flows (rekey's enroll phase, for example) that kick off a provider operation the provider itself may annotate with direct stderr writes. Committing the line immediately means those provider writes don't smear into our formatted prefix.